Measuring memory usage in .Net
I'm trying to get a program I'm writing (in F#, though I would imagine the answer here is the same for any CLR language?) to report on its own memory usage (so I can get an idea of how much I'm stressing the machine, compare sizes of different workloads, and evaluate the effect of any optimizations I do in the hope of saving memory).
The good news is, class Process has plenty of stats available. http://msdn.microsoft.com/en-us/library/system.diagnostics.process_members.aspx
However, there are very many different memory usage figures. Here's four from a test run:
Peak paged memory size 13,492,224
Peak virtual memory size 138,661,888
Peak working set 14,188,544
Private memory size 13,492,224
And there are several others available. What's the difference between them? Which ones are the best answers to "how much memory did the program use on this run it's just finishing now?" And do the same figures have the same meaning on Mono on Linux or MacOS?
对于试图监控自己的内存使用情况的程序来说,看起来最好的数字是GC.GetTotalMemory。
链接地址: http://www.djcxy.com/p/80162.html下一篇: 测量.Net中的内存使用情况