Reputation: 6265
How can i get the size of the current assembly in memory?
This does the trick for once:
while (System.Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64 < 1 gigabyte)
But its not changing the value even though the assembly is growing in memory.
What am I missing here?
Upvotes: 1
Views: 1654
Reputation: 44374
Instead of PrivateMemorySize64
, use WorkingSet64
or VirtualMemorySize64
, depending on whether you mean 'currently in memory' or 'total memory'.
WorkingSet64
gives you the number of bytes that are currently in the machine's RAM.
VirtualMemorySize64
gives you the number of bytes that are in the process's address space. This includes bytes currently in RAM as well as bytes swapped out to disk.
Upvotes: 1