Show: Delphi C++
Display Preferences

System.AllocMemCount

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

AllocMemCount: Integer deprecated; {Unsupported}

C++

extern DELPHI_PACKAGE int AllocMemCount _DEPRECATED_ATTRIBUTE0 ;

Properties

Type Visibility Source Unit Parent
variable public
System.pas
System.hpp
System System

Description

Warning: AllocMemCount is deprecated.

Represents the total number of allocated memory blocks in a Delphi application.

Note: AllocMemCount is the number of currently allocated blocks of memory that were requested by the user. AllocMemCount is incremented each time a block of memory is allocated and is decremented each time a block of memory is freed. Use AllocMemCount to find out how many unfreed blocks of memory remain.

Warning: Because AllocMemCount 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 AllocMemCount. The following table is a summary. Note that applications that use run-time packages are dynamically linked to the RTL, whereas applications that do not are statically linked.
Application type Accessibility of AllocMemCount

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 run-time packages and do not use any statically linked libraries can safely access AllocMemCount 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 also uses libraries that are statically linked to the RTL, then the AllocMemCount variable should never be accessed directly, because the EXE and each library will have their own instance of it. Instead, use the GetAllocMemCount function, implemented in BorlandMM, which returns the instance of the AllocMemCount 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 AllocMemCount in this situation, because global variables in a DLL are private to the DLL.

EXE with packages and statically linked DLLs

You should not create applications that mix run-time packages with statically linked libraries. In this circumstance, use caution when allocating, freeing, and accessing memory. Be aware that each version of the RTL contains an instance of AllocMemCount that references memory that is allocated and freed only by that particular module.


See Also

Personal tools
In Other Languages
Previous Versions
Assistance