1. Home
  2. Computing & Technology
  3. Delphi Programming

Programmatically Get Memory Status

By Zarko Gajic, About.com Guide

To retrieve the current memory status, use the GlobalMemoryStatus() function. The TMemoryStatus contains several fields indicating the status of the memory:

.dwMemoryLoad: Total memory used in percentage (%)
.dwTotalPhys: Total physical memory in bytes.
.dwAvailPhys: Physical memory left in bytes.
.dwTotalPageFile: Total page file in bytes.
.dwAvailPageFile:Page file left in bytes.
.dwTotalVirtual: Total virtual memory in bytes.
.dwAvailVirtual: Virtual memory left in bytes.

Before presenting the memory values, convert them into giga, mega or kilobytes.

var
   Status : TMemoryStatus;
begin
   Status.dwLength := sizeof(TMemoryStatus) ;
   GlobalMemoryStatus(Status) ;

   ShowMessage(Format('Virtual: %d',[Status.dwTotalVirtual])) ;
end;
Delphi tips navigator:
» Exit From Windows
« Programmatically Disable Mouse and Keyboard
Delphi tips navigator:
» Exit From Windows
« Disable mouse and keyboard
Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2001 Delphi Tips
  7. Programmatically Get Memory Status from Delphi

©2009 About.com, a part of The New York Times Company.

All rights reserved.