Question

Would anyone know how to determine RAM usage of a process within the heap? Specifically, how much actual memory is used for .NET objects, as oppossed to the .NET heap size?

Was it helpful?

Solution

That's not possible. At any moment in time, different parts of the virtual memory address space may be swapped out. The operating system uses a most-recently-used algorithm to determine which pages ought to stay in RAM to ensure that the process is least likely to be slowed-down. These selections are highly dynamic and need to run as fast as possible to minimize the delay in getting the other process that needs the RAM running again. Even if you could see the mapping, it would just be a snapshot and very quickly become irrelevant.

The only indication you have is the Environment.WorkingSet property for you own process, Process.WorkingSet64 for another process. But that's just a rough number for the entire process, no way to break it down from there. There is otherwise no winapi function for this, nor can you easily discover the VM-addresses of the GC heap segments. SysInternals' utilities are usually handy for this kind of low-level hacking. However, VMMap doesn't show RAM usage and RAMMap doesn't work on my Win 8.1 machine anymore so I can't tell you how much you can see.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top