RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.AllocMemSize Variable

Represents the total size of allocated memory blocks.

Pascal
AllocMemSize: Integer deprecated;
C++
Integer deprecated AllocMemSize;

System

Note: On Windows, AllocMemSize is the total size, in bytes, of all currently allocated blocks of memory in use by an application. Use AllocMemSize to find out how many bytes of memory an application is currently using.
Note: On Linux, the AllocMemSize variable is not maintained by default. Unless it is updated by a third-party memory manager, this variable always has a value of zero.
Warning: Caution:Because AllocMemSize is a global variable declared in the System unit, it is not always safe to access it directly. In situations where modules are statically linked to the RTL, each module will have a different instance of AllocMemSize. The following table is a summary. Note that applications that use runtime packages are dynamically linked to the RTL, whereas applications that do not are statically linked.

Application type 
Accessibility of AllocMemSize 
EXE  
Applications that do not use packages or Delphi DLLs can safely access this global variable directly because there is only one instance of it.  
EXE with packages and no Delphi DLLs  
Applications that use runtime packages and do not use any statically linked DLLs can safely access AllocMemSize directly. In this situation all modules are dynamically linked to the RTL and there is only one instance of the variable. Unlike standard DLLs, packages allow access to global variables.  
EXE with statically linked DLLs  
If an application is statically linked to the RTL and if that application is also using DLLs that are statically linked to the RTL then the AllocMemSize variable should never be accessed directly, since the EXE and each DLL will have its own instance of it. Instead use the GetAllocMemSize function, implemented in BorlandMM, which returns the instance of the AllocMemSize global variable in the BorlandMM DLL. This DLL manages the memory allocation for all modules that include the ShareMem unit as the first unit in the application or library's uses clause. It is, therefore, this instance of the variable that contains the correct value. A function is used to access AllocMemSize in this situation because global variables in a DLL are private to the DLL.  
EXE with packages and statically linked DLLS  
It is not advisable to create applications that mix runtime packages with statically linked DLLs. In this circumstance use caution when allocating, freeing, and accessing memory. Be aware that each version of the RTL contains an instance of AllocMemSize that references memory that is allocated and freed only by that particular module.  

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!