Mega Code Archive

 
Categories / Delphi / Hardware
 

How to get the used memory for a process

Title: How to get the used memory for a process 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;