No, it won't. Or at least it's not guaranteed that it will work, because the memory managers of the RTL in the library and the one in the application won't be shared.
I was and, still am, under the impression that if _both_ the library and the program are compiled using the same language (as seems to be the case in this particular post) then there should be no problem. Isn't that the case with FPC ?
It isn't the case with FPC, it isn't the case with Delphi or with any language that provides its own memory manager. If you manually allocate memory using some third library (for example the operating system itself using
VirtualAlloc or something like that and the other module uses the corresponding function to free it) then this will work of course, but not if the runtime of the two modules keep track of memory blocks in their own way which is what FPC's memory manager does (and this involves any operation on managed string types, dynamic arrays, classes or even
New and
GetMem). If different memory managers are involved it would be as if you'd use
VirtualAlloc to allocate the memory, but
HeapFree to release it.