Advertisement
WarPie90

MML -> GetProcessMem

Dec 10th, 2015
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.43 KB | None | 0 0
  1. uses {MML}StringUtil;
  2.  
  3. (*
  4.   Returns (resident) memory usage of a process in kB.
  5. *)
  6. function GetProcessMem(proc:UInt32): UInt64;
  7. var
  8.   list: TStringList;
  9. begin
  10.   Result := 0;
  11.   list := TStringList.Create;
  12.   try
  13.     list.NameValueSeparator:=':';
  14.     list.LoadFromFile( Format('/proc/%d/status', [proc]) );
  15.     Result := StrToInt64( ExtractFromStr(list.Values['VmRSS'], NUMBERS) );
  16.   finally
  17.     list.Free();
  18.   end;
  19. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement