如何读取我的程序中其他应用程序使用的内存量? [英] How Can I Read the Amount of Memory Being Used by Another Application Within My Program?
问题描述
让我解释为什么我需要知道,在我的服务器启动器(对于游戏)中,有人要求我添加了重启内存过多使用复选框。所以,经过一个小时左右的冒险,我来到这里。
我只需要知道如何读取正在运行的应用程序的内存使用情况我可以做休息。我只是不知道如何使用ac#应用程序。
到目前为止我所拥有的是
To let me explain why I need to know, in my server launcher (for a game) someone requested that I added a 'Restart on Excessive Memory Usage' checkbox. So, after an hour or so of adventuring, I came here.
I just need to know how to read the memory usage of a running application and I can do the rest. I just have no idea how to do this withing a c# application.
What I have so far is
Process[] p = System.Diagnostics.Process.GetProcessesByName("ProcessName");
然后我需要得到WorkingSet,但我不能这样做,因为它是一个数组。无论如何要解决这个问题吗?
谢谢!
Then I need to get the WorkingSet, but I can't do this as it's an array. Is there anyway to fix this?
Thank you!
推荐答案
请参阅:http://social.msdn。 microsoft.com/Forums/vstudio/en-US/7d8a6640-919d-47d8-8e73-586fb7ac261e/get-processs-memory?forum=csharpgeneral [ ^ ],
http://stackoverflow.com/questions/4679962/what-is-the-correct-performance-counter-to-get-cpu-and-memory-usage-of-a-process 一> [ ^ ]。
有关背景信息,请参阅此Microsoft文章:http://technet.microsoft.com/en-us/library/cc768048.aspx [ ^ ]。
-SA
Please see: http://social.msdn.microsoft.com/Forums/vstudio/en-US/7d8a6640-919d-47d8-8e73-586fb7ac261e/get-processs-memory?forum=csharpgeneral[^],
http://stackoverflow.com/questions/4679962/what-is-the-correct-performance-counter-to-get-cpu-and-memory-usage-of-a-process[^].
For the background, please see this Microsoft article: http://technet.microsoft.com/en-us/library/cc768048.aspx[^].
—SA
这篇关于如何读取我的程序中其他应用程序使用的内存量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!