Class ProcessMemory
- Namespace
- PopcorningGuineaPig.Engine.Diagnostics
- Assembly
- PopcorningGuineaPig.Engine.dll
Working set and private bytes for the current process, read without the cost of Process.
public static class ProcessMemory
- Inheritance
-
ProcessMemory
- Inherited Members
Remarks
WorkingSet64 and PrivateMemorySize64 look like
field reads and are not. On Windows the first property access after Refresh()
loads the system-wide process table, and the cost scales with how many processes the machine
is running — measured here at 750–1700 ms on every snapshot, not just the first.
That is 20x the profiler's own 50 ms budget, and it made per-frame or per-second sampling
impossible. GetProcessMemoryInfo reads this process only: ~0.007 ms.
The counters are the same ones Process reports (verified against it), so snapshots stay comparable across the change.
Methods
Read()
Reads current-process working set and private bytes. Never throws.
public static (long WorkingSet, long Private) Read()