legacymem.pp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. unit legacymem;
  2. // temporary unit to bridge all the getfpcheapstatus/getheapstatus/memavail
  3. // problems in tests and demoes.
  4. interface
  5. function getUsedbytes :PtrInt;
  6. function getTotalBytes :PtrInt;
  7. implementation
  8. {$ifndef HASGETHEAPSTATUS}
  9. type
  10. THeapStatus = record
  11. MaxHeapSize,
  12. MaxHeapUsed,
  13. CurrHeapSize,
  14. CurrHeapUsed,
  15. CurrHeapFree : ptrint;
  16. end;
  17. {$endif HASGETHEAPSTATUS}
  18. {$ifndef HASGETFPCHEAPSTATUS}
  19. type
  20. TFPCHeapStatus = THeapStatus;
  21. {$endif HASGETFPCHEAPSTATUS}
  22. {$ifndef HASGETHEAPSTATUS}
  23. procedure getheapstatus(var status:THeapStatus);
  24. begin
  25. fillchar(status,sizeof(status),0);
  26. status.MaxHeapSize:=HeapSize;
  27. status.MaxHeapUsed:=HeapSize-MemAvail;
  28. status.CurrHeapSize:=HeapSize;
  29. status.CurrHeapUsed:=HeapSize-MemAvail;
  30. status.CurrHeapFree:=MemAvail;
  31. end;
  32. {$endif HASGETHEAPSTATUS}
  33. {$ifndef HASGETFPCHEAPSTATUS}
  34. function GetFPCHeapStatus:TFPCHeapStatus;
  35. begin
  36. GetHeapStatus(GetFPCHeapStatus);
  37. end;
  38. {$endif HASGETFPCHEAPSTATUS}
  39. function getTotalBytes :PtrInt;
  40. begin
  41. gettotalbytes:=GetFPCHeapStatus.CurrHeapsize;
  42. end;
  43. function getUsedBytes :PtrInt;
  44. begin
  45. getusedbytes:=GetFPCHeapStatus.CurrHeapsize;
  46. end;
  47. end.