Memory management in Delphi[1]
// TMemoryStatus is a rename of _MEMORYSTATUS: _MEMORYSTATUS = record dwLength: DWORD; {structure length} dwMemoryLoad: DWORD; {an integer representing the proportion of memory used} dwTotalPhys: DWORD; {total physical memory} dwAvailPhys: DWORD; {Total available physical memory} dwTotalPageFile: DWORD; {Total virtual memory} dwAvailPageFile: DWORD; {Total available virtual memory} dwTotalVirtual: DWORD; {Total number of addresses in the virtual address table} dwAvailVirtual: DWORD; {Total number of addresses available in the virtual address table} end ;
Make a small program to see the memory situation:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 =class (TForm) Memo1: TMemo; procedure FormCreate (Sender: TObject); end ; var Form1: TForm1; implementation {$ R * .dfm} procedure TForm1.FormCreate (Sender: TObject); var m: TMemoryStatus; const num =1024 * 1024; begin GlobalMemoryStatus (m); Memo1.Clear; with Memo1.Linesdo begin Add (Format ('dwLength:' + #9 + '% d', [m.dwLength])); Add (Format ('dwMemoryLoad:' + #9 + '% d', [m.dwMemoryLoad])); Add (Format ('dwTotalPhys:' + #9 + '% d', [m.dwTotalPhys div num])); Add (Format ('dwAvailPhys:' + #9 + '% d', [m.dwAvailPhys div num])); Add (Format ('dwTotalPageFile:' + #9 + '% d', [m.dwTotalPageFile div num])); Add (Format ('dwAvailPageFile:' + #9 + '% d', [m.dwAvailPageFile div num])); Add (Format ('dwTotalVirtual:' + #9 + '% d', [m.dwTotalVirtual div num])); Add (Format ('dwAvailVirtual:' + #9 + '% d', [m.dwAvailVirtual div num])); end ; end ; end .