如何确定我的 .NET 程序使用了多少内存?
人们似乎经常说任务管理器不能准确指示进程使用了多少内存。
如果确实如此,找出这些问题的最简单方法是什么?
我想知道:
- 使用中的总内存(无论是在 RAM 中还是分页还是其他)
- 使用中的总 RAM(在机器具有大量可用物理 RAM 的情况下运行,因此希望强制调出的内容不是问题)
- 程序实际使用的总内存(不计算 GC 保留的额外开销)
- 只由我的程序使用的总内存使用量(不计算共享库/共享内存)
- 总共享内存使用量。
It seems to be often said that Task Manager does not provide an accurate indication of how much memory is in use by a process.
If this is indeed the case, what's the easiest way to find these things out?
I'd like to know:
- Total Memory in use (whether in RAM or paged or whatever)
- Total RAM in use (running in a situation where the machine has loads of free physical RAM so things getting forcibly paged out hopefully isn't an issue)
- Total Memory actually used by the program (not counting the extra overhead the GC keeps around)
- Total Memory usage that is solely used by my program (not counting shared libraries/shared memory)
- Total Shared memory usage.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
抓住 Process Explorer,右键单击 -> 属性列表中的进程,然后单击“.NET”选项卡。 从组合框中选择“.NET CLR Memory”,您将获得更多有关进程的实时信息,而不知道如何处理;)
Grab Process Explorer, right-click -> Properties the process in the list, and then click the ".NET" tab. Select ".NET CLR Memory" from the combobox, and you'll have more live info about your process than you'll know what to do with ;)
http://memprofiler.com/ 是一个非常好的.Net 内存分析器。 但是 Microsoft 内置的 Windows 性能监视器 (perfmon) 也会为您提供这些数据。 请参阅http://dotnetdebug.net/2005/06/30/ perfmon-your-debugging-buddy/ 为此。
http://memprofiler.com/ is a very good .Net memory profiler. But Microsoft's build into Windows Performance Monitor (perfmon) will also give you those figures. See http://dotnetdebug.net/2005/06/30/perfmon-your-debugging-buddy/ for that.
您可以做一些事情,但我相信,如果您认真分析您的应用程序,最好的办法是使用 Red Gate 的 Ants Profiler:
http://www.red-gate.com/Products/ants_profiler/index.htm
这个软件非常全面,会给很好地了解您的应用程序呈现的内存使用情况和其他类型的指标。
There are some things you can do but I believe the best thing out there, if you're serious about profiling your application, is to use the Ants Profiler by Red Gate:
http://www.red-gate.com/Products/ants_profiler/index.htm
This software is really comprehensive and will give a good picture what sorts of memory usage and other sorts of metrics your app presents.
启动性能监视器 (perfmon.exe) 并查看 .Net CLR 内存性能对象。 每个正在运行的 .net 程序都有自己的实例。 您应该能够在那里找到您想要的东西。
Start Performance Monitor (perfmon.exe) and take a look at the .Net CLR Memory performance object. Every running .net program has its own instance. You should be able to find what you want there.
如果您双击,Process Explorer 将向您显示其中的一些内容在一个过程上。
Process Explorer will show you some of this if you double-click on on a process.
SysInternals ProcessExplorer 包括一个 .NET 分析器,但如果您需要专业工具,ANTS 是您的最佳选择。
There are some good features in the SysInternals ProcessExplorer including a .NET profiler, though ANTS is the way to go if you need a pro tool.
我也使用 memprofiler,它对我们帮助很大。
I use memprofiler as well and it helped us out tremendously.