Monitoring Memory Usage

From RAD Studio
Jump to: navigation, search

Go Up to Managing Memory Index

This section describes how to monitor the state of the Memory Manager on Win32 and Win64. Posix/32 memory manager does not support this functionality.

The Memory Manager provides two procedures that allow the application to monitor its own memory usage and the state of the process's address space. Both functions are thread safe.

To monitor memory usage for your application:

  1. Call the procedure GetMemoryManagerState.
  2. Inspect the populated TMemoryManagerState structure and extract the needed Memory Manager state information. The structure has fields detailing the total number of allocations, the sum of their sizes, as well as the total reserved address space. The statistics are subdivided into three categories: small, medium and large allocations.

To get a map of the memory address space for a process

  1. Call the procedure GetMemoryMap.
  2. Inspect the populated TMemoryMap array and extract the needed information regarding the process' address space. The array contains a TChunkStatus entry for every possible 64K block in the process' address space.

See Also