我有一个在 C# 中使用线程的程序。有没有办法以编程方式了解应用程序的内存使用情况?我想将线程的产生限制为 10 MB 内存,我该怎么做?
如果您想要整个正在运行的进程的内存而不是每个线程的内存,那么:
// get the current process
Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();
// get the physical mem usage
long totalBytesOfMemoryUsed = currentProcess.WorkingSet64;
除此之外,还有许多其他进程内存属性WorkingSet64
在以下链接中查看“与内存相关”的内容,以找到最适合的内容
http://msdn.microsoft.com/en-us/library/system.diagnostics.process_properties.aspx http://msdn.microsoft.com/en-us/library/system.diagnostics.process_properties.aspx
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)