Shared-memory
manager (Windows only)
On
Windows, if a DLL exports routines that pass long strings or dynamic arrays as
parameters or function results (whether directly or nested in records or
objects), then the DLL and its client applications (or DLLs) must all use the ShareMem
unit. The same is true if one application or DLL allocates memory with New
or GetMem which is deallocated by a call to Dispose or FreeMem
in another module. ShareMem should always be the first unit listed in
any program or library uses clause where it occurs.
ShareMem is the interface unit for the BORLANDMM.DLL memory manager, which
allows modules to share dynamically allocated memory. BORLANDMM.DLL must be
deployed with applications and DLLs that use ShareMem. When an
application or DLL uses ShareMem, its memory manager is replaced by the
memory manager in BORLANDMM.DLL.
Linux uses glibc’s malloc to manage shared memory.
Writing dynamically loadable libraries
共享内存管理(仅适用于Windows)
在Windows中,如果动态链接库(DLL)输出的例程把长串或动态数组作为参数传递或者作为函数结果(不管直接存在还是嵌套于记录或对象中),那么动态链接库及其客户应用程序(或动态链接库)都必需使用ShareMem单元。同样,如果一个应用程序或动态链接库(DLL)用New或GetMem分配的内存,而被另一个模块中的的Dispose或FreeMem释放,那么它们也必须都使用ShareMem单元。如果一个uses子句中需要出现ShareMem单元,那么该单元总是列于首位。
ShareMem单元是内存管理模块BORLANDMM.DLL的接口单元,它允许模块之间共享动态分配的内存。BORLANDMM.DLL必须被使用了ShareMem单元的应用程序或动态链接库(DLL)从内存中销毁。当一个应用程序或DLL使用了ShareMem时,其内存管理被BORLANDMM.DLL中的内存管理模块代替。
Linux用glibc的malloc例程管理共享内存。