.NET 应用程序的内存消耗详细信息
我正在调试与我们拥有的托管应用程序相关的一些内存问题。 当我对所有堆中的 .NET 字节与 Process Explorer 中报告的工作集(如果是任务管理器的内存使用列)之间的内存差异感到困惑时,我正在使用 perfmon 监视应用程序。 所有堆中的字节计数器显示的值为 15MB,而进程工作集为 78MB - 这是一个巨大的差异。 我知道加载到内存中的文件会消耗一定量的内存,但这些数字仍然没有相加。
有什么线索吗?
I am debugging some memory problems related to a managed application that we have. I was monitoring the application using perfmon when I got confused about the memory difference between the .NET Bytes in All Heaps and the Working Set reported in Process Explorer (Mem Usage column in case of Task Manager). The Bytes in all heaps counter displays the value as 15MB whereas the process working set is 78MB - a huge difference. I understand that some amount of memory would be consumed in the files loaded in memory, but still the numbers don't add up.
Any clues?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试使用 FXCop。 查看有关在 IDisposable 类型上调用 dispose 失败的规则。
.net 中内存泄漏的主要原因有两个,一是未能调用 IDisposable(这是一种为 P/Invoke 代码调用非托管析构函数的技术),二是未能释放对对象的引用,这导致它们不垃圾收集。 例如,如果您将对象存储在列表中,您可能会意外地保留对列表的引用,从而使对象仍然保留在内存中。
Try and get your hands on FXCop. Have a look for the rule regarding the failure to call dispose on IDisposable types.
There are two main causes of memory leaks in .net, which are failure to call IDisposable (which is a technique that will call unmanaged destructors for P/Invoke code) and the second is failing to release references to objects, which causes them to not garbage collect. For instance if you are storing objects in a list, you may accidentally be keeping a reference to a list and thus an object still in memory.
这篇文章提供了对各种内存计数器的良好概述。
从您的问题描述来看,您似乎正在使用大约 63MB 的非托管内存。
This article gives a good overview of the various memory counters.
From your question description, it seems that you have approx. 63MB of unmanaged memory in use.
Rico Mariani 的 Performance Tidbits 博客文章 跟踪托管内存泄漏(如何发现GC泄漏)并不能直接回答您的问题re:所有堆和工作集中的字节,但它应该对您的任务re:调试与托管应用程序相关的一些内存问题有很大帮助。
您可能还需要查看为了更好地使用内存而需要避免的两件事 和 跟踪由于以下原因导致的内存泄漏的三种技术未处理的对象。
所有文章都已经很老了,但是所提供的信息仍然对您有帮助。
Rico Mariani's Performance Tidbits blog post Tracking down managed memory leaks (how to find a GC leak) does not directly answer your question re: Bytes in All Heaps and the Working Set, but it should help considerably with your task re:debugging some memory problems related to a managed application.
You may also want to review Two things to avoid for better memory usage and Three techniques for tracking down memory leaks due to undisposed objects.
All of the articles are quite old, but the information presented should still be helpful to you.