Show memory usage of application lazarus / 31-LCL ---------------------------------------------------------------------- totya · 2011-02-01 09:24 Hi! I want see memory usage of my application in my application. This is possible? ---------------------------------------------------------------------- marcov · 2011-02-01 09:39 Search in the help/docs for getheapstatus and getfpcheapstatus. IIRC they come with examples. ---------------------------------------------------------------------- totya · 2011-02-02 14:38 Quote from: marcov on February 01, 2011, 10:39:59 amSearch in the help/docs for getheapstatus and getfpcheapstatus. IIRC they come with examples. Thanks, I see. But I don't know what is this :"IIRC". ---------------------------------------------------------------------- ik · 2011-02-02 15:24 Quote from: totya on February 02, 2011, 03:38:48 pmQuote from: marcov on February 01, 2011, 10:39:59 amSearch in the help/docs for getheapstatus and getfpcheapstatus. IIRC they come with examples. Thanks, I see. But I don't know what is this :"IIRC". Abbreviation for "If I Recall Correctly" ---------------------------------------------------------------------- totya · 2011-02-02 15:51 Quote from: ik on February 02, 2011, 04:24:25 pmQuote from: totya on February 02, 2011, 03:38:48 pm... I don't know what is this :"IIRC".Abbreviation for "If I Recall Correctly" Thanks ---------------------------------------------------------------------- Dibo · 2011-02-03 17:57 Records returned by this funcions has many variables but none reflect memory usage which show system (windows) task manager. Exists any function to get this? ---------------------------------------------------------------------- peardox · 2011-02-08 12:06 I've been trying to find out how to do this for about a week. I got bored up of looking for a spoon-fed answer so decided to work it out myself. A quick play gets me the example below - the number you're after is WorkingSetSize Windows ONLY!!! Drop a memo and button onto a form then do this... Code: [Select]unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,   StdCtrls, jwapsapi, jwawinbase, jwawinnt; type   { TForm1 }   TForm1 = class(TForm)     Button1: TButton;     Memo1: TMemo;     procedure Button1Click(Sender: TObject);   private     { private declarations }   public     { public declarations }   end; var   Form1: TForm1; implementation { TForm1 } procedure TForm1.Button1Click(Sender: TObject); var   psmemCounters: _PROCESS_MEMORY_COUNTERS;   ThisApp: LongWord; begin   ThisApp := GetCurrentProcessID();   ThisApp := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, FALSE, ThisApp );   if( ThisApp = LongWord(0)) then     begin     Application.Messagebox('OpenProcess Error', 'Error', 0);     exit;     end;   if(GetProcessMemoryInfo(ThisApp, psmemCounters, sizeof(_PROCESS_MEMORY_COUNTERS)) <> LongBool(0)) then     begin     Memo1.Clear;     Memo1.lines.add('WorkingSetSize ' + IntToStr(psmemCounters.WorkingSetSize));     Memo1.lines.add('');     Memo1.lines.add('PageFileUsage ' + IntToStr(psmemCounters.PagefileUsage));     Memo1.lines.add('QuotaNonPagedPoolUsage ' + IntToStr(psmemCounters.QuotaNonPagedPoolUsage));     Memo1.lines.add('QuotaPagedPoolUsage ' + IntToStr(psmemCounters.QuotaPagedPoolUsage));     Memo1.lines.add('PageFaultCount ' + IntToStr(psmemCounters.PageFaultCount));     Memo1.lines.add('');     Memo1.lines.add('PeakWorkingSetSize ' + IntToStr(psmemCounters.PeakWorkingSetSize));     Memo1.lines.add('PeakPageFileUsage ' + IntToStr(psmemCounters.PeakPagefileUsage));     Memo1.lines.add('QuotaPeakNonPagedPoolUsage ' + IntToStr(psmemCounters.QuotaPeakNonPagedPoolUsage));     Memo1.lines.add('QuotaPeakPagedPoolUsage ' + IntToStr(psmemCounters.QuotaPeakPagedPoolUsage));     end   else     begin     Application.Messagebox('GetProcessMemoryInfo Error', 'Error', 0);     end;   CloseHandle(ThisApp); end; initialization   {$I unit1.lrs} end. I just threw this together then compared it to Windows Task Manager's value and it was correct (more accurate I guess as it reports to the byte rather than in k) Useless for cross-platform of course