Kylix
Tips

NEW TIPS
Database (135)
Files (612)
Forms (606)
Graphic (536)
IDE (456)
Indy (433)
Internet / LAN (590)
IntraWeb (443)
Kylix (447)
Math (561)
Misc (591)
Multimedia (496)
Objects/
ActiveX (503)

OpenTools API (438)
Printing (459)
Strings (583)
System (721)
VCL (586)

Search Tip
Top15
Add new Tip

Forum

...get the used memory for a process?
Author: Evgeny V. Levashov
[ Print tip ]    

Tip Rating (1):  
     



// Works only on Windows NT systems (WinNT, Win2000, WinXP)

// Funktioniert nur unter Windows NT Systemen (WinNT, Win2000, WinXP)

uses psAPI;

procedure TForm1.Button1Click(Sender: TObject);
var
  
pmc: PPROCESS_MEMORY_COUNTERS;
  cb: Integer;
begin
  
cb := SizeOf(_PROCESS_MEMORY_COUNTERS);
  GetMem(pmc, cb);
  pmc^.cb := cb;
  if GetProcessMemoryInfo(GetCurrentProcess(), pmc, cb) then
    
Label1.Caption := IntToStr(pmc^.WorkingSetSize) + ' Bytes'
  else
    
Label1.Caption := 'Unable to retrieve memory usage structure';

  FreeMem(pmc);
end;

Rate this tip:

poor
very good


Copyright © Torry's Delphi Pages Torry's Delphi Pages Maintained by Simon Grossenbacher Notes? Comments? Feel free to send... Copyright © 1996-2001