Unix.WMPerfMonPluginMemory.Mod 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. MODULE WMPerfMonPluginMemory; (** AUTHOR "staubesv"; PURPOSE "Performance Monitor memory utilization plugin"; *)
  2. IMPORT
  3. Modules, WMPerfMonPlugins, Heaps;
  4. CONST
  5. ModuleName = "WMPerfMonPluginMemory";
  6. TYPE
  7. (* Heaps.GetHeapInfo is a slow operation. HeapHelper provides its results to multiple plugins *)
  8. HeapHelper = OBJECT(WMPerfMonPlugins.Helper)
  9. VAR
  10. free, total, largest : SIZE;
  11. PROCEDURE Update;
  12. BEGIN
  13. Heaps.GetHeapInfo(total, free, largest);
  14. END Update;
  15. END HeapHelper;
  16. TYPE
  17. MemoryLoad* = OBJECT(WMPerfMonPlugins.Plugin)
  18. VAR
  19. h : HeapHelper;
  20. PROCEDURE Init*(p : WMPerfMonPlugins.Parameter);
  21. VAR ds : WMPerfMonPlugins.DatasetDescriptor;
  22. BEGIN
  23. p.name := "Heap"; p.description := "Heap statistics"; p.modulename := ModuleName;
  24. p.autoMax := TRUE; p.unit := "KB"; p.minDigits := 7;
  25. p.noSuperSampling := TRUE;
  26. p.helper := heapHelper; h := heapHelper;
  27. NEW(ds, 3);
  28. ds[0].name := "Size"; INCL(ds[0].flags, WMPerfMonPlugins.Maximum);
  29. ds[1].name := "Free";
  30. ds[2].name := "LargestBlock"; INCL(ds[2].flags, WMPerfMonPlugins.Standalone);
  31. p.datasetDescriptor := ds;
  32. END Init;
  33. PROCEDURE UpdateDataset*;
  34. BEGIN
  35. dataset[0] := h.total DIV 1024;
  36. dataset[1] := h.free DIV 1024;
  37. dataset[2] := h.largest DIV 1024;
  38. END UpdateDataset;
  39. END MemoryLoad;
  40. VAR
  41. heapHelper : HeapHelper;
  42. PROCEDURE InitPlugins;
  43. VAR
  44. par : WMPerfMonPlugins.Parameter;
  45. ml : MemoryLoad;
  46. BEGIN
  47. NEW(par); NEW(ml, par);
  48. END InitPlugins;
  49. PROCEDURE Install*;
  50. END Install;
  51. PROCEDURE Cleanup;
  52. BEGIN
  53. WMPerfMonPlugins.updater.RemoveByModuleName(ModuleName);
  54. END Cleanup;
  55. BEGIN
  56. NEW(heapHelper);
  57. InitPlugins;
  58. Modules.InstallTermHandler(Cleanup);
  59. END WMPerfMonPluginMemory.
  60. WMPerfMonPluginMemory.Install ~ System.Free WMPerfMonPluginMemory ~