Advertisement
D98rolb

Untitled

Mar 14th, 2024
919
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.81 KB | Source Code | 0 0
  1. procedure TraceMemUsage;
  2. var
  3.   i, j: Integer;
  4.   Form: TCustomForm;
  5.   Msg: string;
  6.   vResult: THeapStatus;
  7. begin
  8.   vResult := GetHeapStatus;
  9.   TraceLog.Trace('*** HEAP STATUS ***');
  10.   TraceLog.Trace(Format('    Used memory Win32: %d', [MemoryUsed]));
  11.   TraceLog.Trace(Format('    Total Adress Space: %d', [vResult.TotalAddrSpace]));
  12.   TraceLog.Trace(Format('    Total Uncommitted: %d', [vResult.TotalUncommitted]));
  13.   TraceLog.Trace(Format('    Total Committed: %d', [vResult.TotalCommitted]));
  14.   TraceLog.Trace(Format('    Total Allocated: %d', [vResult.TotalAllocated]));
  15.   TraceLog.Trace(Format('    Total Free: %d', [vResult.TotalFree]));
  16.   TraceLog.Trace(Format('    Free Small: %d', [vResult.FreeSmall]));
  17.   TraceLog.Trace(Format('    Free Big: %d', [vResult.FreeBig]));
  18.   TraceLog.Trace(Format('    Unused: %d', [vResult.Unused]));
  19.   TraceLog.Trace(Format('    Overhead: %d', [vResult.Overhead]));
  20.   TraceLog.Trace(Format('    Heap Error Code: %d', [vResult.HeapErrorCode]));
  21.   TraceLog.Trace(Format('    AllocMemSize: %d', [AllocMemSize]));
  22.   TraceLog.Trace(Format('    AllocMemCount: %d', [AllocMemCount]));
  23.  
  24.   TraceLog.Trace('*** FORM STATUS ***');
  25.   TraceLog.Trace(Format('There are %d forms remaining in memory.', [Screen.CustomFormCount]));
  26.  
  27.   for i := 0 to Screen.CustomFormCount-1 do
  28.   begin
  29.     Form := Screen.CustomForms[i];
  30.     Msg := '#' + IntToStr(i+1) +
  31.            '  ClassName=' +  Form.ClassName +
  32.            '  Name=' + Form.Name +
  33.            '  Visible=' + BoolToStr(Form.Visible, True) +
  34.            '  Owner=';
  35.     if Assigned(Form.Owner) then
  36.       Msg := Msg + Form.Owner.ClassName
  37.     else
  38.     begin
  39.       Msg := Msg + 'NIL   -- COMPONENTS:';
  40.       for j := 0 to Form.ControlCount-1 do
  41.         Msg := Msg + Form.Controls[j].Name + ', ';
  42.     end;
  43.     TraceLog.Trace(Msg);
  44.   end;
  45. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement