Your full service technology partner! 
-Collapse +Expand
Search Delphi Group:

-Collapse +Expand Delphi To/From
-Collapse +Expand Delphi Store

Prestwood eMagazine

October Edition
Subscribe now! It's Free!
Enter your email:

   ► KBProgrammingDelphi for W...Using Data   Print This     
  From the June 2008 Issue of Prestwood eMag
Delphi Using Data:
Using GetHeapStatus
Posted 13 years ago on 2/26/2008 and updated 1/28/2009
Take Away: Memory Management and Delphi


GetHeapStatus returns the current status of the memory manager in a THeapStatus record. Together they provide a view into how Windows is handling the memory requirements for your application.

GetHeapStatus can be used to analyze a run-away application (Note: GetHeapStatus only applies to the memory used by the application that calls it). Each application is assigned its own heap and calling GetHeapStatus returns information specific to that memory pool.

THeapStatus is a record structure that is filled by Windows when you call GetHeapStatus. THeapStatus contains the following fields:

The (current) total address space available to your pascal program, in bytes. This will grow as your program's dynamic memory usage grows.
The total number of bytes (of TotalAddrSpace) for which space has not been allocated in the swap file.
The total number of bytes (of TotalAddrSpace for which space has been allocated in the swap file.
The total number of bytes dynamically allocated by your program.
The total number of free bytes available in the (current) address space for allocation by your program. If this number is exceeded, and enough virtual memory is available, more address space will be allocated from the OS; TotalAddrSpace will be incremented accordingly.
Total bytes of small memory blocks which are not currently allocated by your program.
Total bytes of big memory blocks which are not currently allocated by your program. Large free blocks can be created by coalescing smaller, contiguous, free blocks or by freeing a large dynamic allocation.
Total bytes which have never been allocated by your program.
The total number of bytes required by the heap manager to manage all the blocks dynamically allocated by your program.
Indicates the current status of the heap, as internally determined.

Here is an example of using GetHeapStatus to determine the TotalAddrSpace:
procedure TForm1.Button1Click(Sender: TObject);
  hStatus : THeapStatus;  
  hStatus := GetHeapStatus;
  ShowMessage('Total Address ' + 'Space =' + IntToStr(hStatus.TotalAddrSpace));


Share a thought or comment...
Comment 1 of 3

I read in the Dephi 7 help that GetHeapStatus may return different values, wether you include or not the ShareMem unit.

Posted 13 years ago

Comment 2 of 3

Yes, if you include ShareMem, GetHeapStatus returns information about memory that can be shared between different processes.

Posted 12 years ago

Comment 3 of 3

Excellent to read the post! They always share some useful content on their behalf. They give us many solutions regarding our technological problems but now I can check customwritings to find quality work. In this particular page they are sharing getheapstatus regarding information with proper guidelines.

Posted 17 months ago
Write a Comment...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.

Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1274A1
Enter key:
KB Post Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile

 KB Article #100885 Counter
Since 4/2/2008
Sales Website: Or visit our legacy sales site:

©1995-2021 Prestwood IT Solutions.   [Security & Privacy]