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

Advanced
-Collapse +Expand Delphi To/From
To/FromCODEGuides
-Collapse +Expand Delphi Store
PRESTWOODSTORE

Prestwood eMagazine

March 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 11 years ago on 2/26/2008 and updated 1/28/2009
Take Away: Memory Management and Delphi

KB100885



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
THeapStatus is a record structure that is filled by Windows when you call GetHeapStatus. THeapStatus contains the following fields:

TotalAddrSpace
The (current) total address space available to your pascal program, in bytes. This will grow as your program's dynamic memory usage grows.
TotalUncommited
The total number of bytes (of TotalAddrSpace) for which space has not been allocated in the swap file.
TotalCommited
The total number of bytes (of TotalAddrSpace for which space has been allocated in the swap file.
TotalAllocated
The total number of bytes dynamically allocated by your program.
TotalFree
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.
FreeSmall
Total bytes of small memory blocks which are not currently allocated by your program.
FreeBig
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.
Unused
Total bytes which have never been allocated by your program.
Overhead
The total number of bytes required by the heap manager to manage all the blocks dynamically allocated by your program.
HeapErrorCode
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);
var
  hStatus : THeapStatus;  
 
begin
  hStatus := GetHeapStatus;
  ShowMessage('Total Address ' + 'Space =' + IntToStr(hStatus.TotalAddrSpace));
end;

Comments

1 Comments.
Share a thought or comment...
Comment 1 of 2

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

Posted 11 years ago

Comment 2 of 2

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

Posted 10 years 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 = P1263A1
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 play-drums.com 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
11672
Since 4/2/2008
-
   Contact Us!
 
Have a question? Need our services? Contact us now.
--Mike Prestwood

Call: 916-726-5675

email: info@prestwood.com


Go ahead!   Use Us! Call: 916-726-5675 


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