.NET 内存分析工具
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/399847/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
.NET Memory Profiling Tools
提问by nick_alot
Possible Duplicate:
What Are Some Good .NET Profilers?
可能的重复:有
哪些好的 .NET Profiler?
I am on the lookout for good .NET CLR memory profiling tools.
我正在寻找好的 .NET CLR 内存分析工具。
My key requirement is that it will play well with IIS and standalone CLR Apps. Ideally I would see what objects are allocated, where they are allocated and what size they are?
我的主要要求是它可以很好地与 IIS 和独立的 CLR 应用程序配合使用。理想情况下,我会看到分配了哪些对象,分配了哪些对象以及它们的大小?
Does anyone have any good experiences with a particular tool that you would be happy to recommend?
有没有人对您很乐意推荐的特定工具有任何好的经验?
采纳答案by Ben Robbins
I'm currently evaluating both the Scitech .NET Memory Profiler 3.1and ANTS Memory Profiler 5.1. I tried the JetBrains one a year or two ago and it wasn't as good as ANTS so I haven't bothered this time. From reading the web sites it looks like it isn't as good for memoryprofiling as the other two.
我目前正在评估Scitech .NET Memory Profiler 3.1和ANTS Memory Profiler 5.1。我在一两年前尝试过 JetBrains,但它不如 ANTS,所以这次我没有打扰。从阅读网站来看,它看起来不像其他两个那样适合内存分析。
Both ANTS and the Scitech memory profiler have features that the other doesn't, so which is best will depend upon your preferences. Generally speaking, the Scitech one provides more detailed information while the ANTS one is really incredible at identifying the leaking object. Overall, I prefer the ANTS one because it is so quick at identifying possible leaks.
ANTS 和 Scitech 内存分析器都具有另一个没有的功能,因此哪个最好取决于您的喜好。一般来说,Scitech one 提供了更详细的信息,而 ANTS one 在识别泄漏对象方面确实令人难以置信。总的来说,我更喜欢 ANTS,因为它可以快速识别可能的泄漏。
Here are the main the pros and cons of each from my experience:
根据我的经验,以下是每种方法的主要优缺点:
Common Features of ANTS and Scitech .NET Memory Profiler
ANTS 和 Scitech .NET Memory Profiler 的共同特点
- Real-time analysis feature
- Excellent how-to videos on their web sites
- Easy to use
- Reasonably performant (obviously slower than without the profiler attached, but not so much you become frustrated)
- Show instances of leaking objects
- Basically they both do the job pretty well
- 实时分析功能
- 他们网站上的优秀操作视频
- 便于使用
- 合理的性能(显然比没有附加分析器要慢,但不会让你感到沮丧)
- 显示泄漏对象的实例
- 基本上他们都做得很好
ANTS
蚂蚁
- One-click filters to find common leaksincluding: objects kept alive only by event handlers, objects that are disposed but still live and objects that are only being kept alive by a reference from a disposed object. This is probably the killer feature of ANTS - finding leaks is incredibly fast because of this. In my experience, the majority of leaks are caused by event handlers not being unhooked and ANTS just takes you straight to these objects. Awesome.
- Object retention graph. While the same info is available in Scitech, it's much easier to interpret in ANTS.
- Shows size with children in addition to size of the object itself (but only when an instance is selected unfortunately, not in the overall class list).
- Better integration to Visual Studio (right-click on graph to jump to file)
- 用于查找常见泄漏的一键式过滤器,包括:仅通过事件处理程序保持活动状态的对象、已释放但仍处于活动状态的对象以及仅通过来自已释放对象的引用保持活动状态的对象。这可能是 ANTS 的杀手级功能——因此发现泄漏的速度非常快。根据我的经验,大多数泄漏是由于事件处理程序没有被解开而引起的,ANTS 只是将您直接带到这些对象。惊人的。
- 对象保留图。虽然 Scitech 中提供了相同的信息,但在 ANTS 中更容易解释。
- 除了对象本身的大小外,还显示子项的大小(但仅当不幸选择了一个实例时,而不是在整个类列表中)。
- 更好地集成到 Visual Studio(右键单击图形以跳转到文件)
Scitech .NET Memory Profiler
Scitech .NET 内存分析器
- Shows stack trace when object was allocated. This is reallyuseful for objects that are allocated in lots of different places. With ANTS it is difficult to determine exactly where the leaked object was created.
- Shows count of disposable objects that were not disposed. While not indicative of a leak, it does identify opportunities to fix this problem and improve your application performance as a result of faster garbage collection.
- More detailed filtering options (several columns can be filtered independently).
- Presents info on total objects created (including those garbage collected). ANTS only shows 'live' object stats. This makes it easier to analyze and tune overall application performance (eg. identify where lots of objects being created unnecessarily that aren't necessarily leaking).
- 分配对象时显示堆栈跟踪。这对于分配在许多不同地方的对象非常有用。使用 ANTS 很难准确确定泄漏对象的创建位置。
- 显示未处理的一次性对象的计数。虽然不表示泄漏,但它确实识别了修复此问题的机会,并通过更快的垃圾收集提高了应用程序性能。
- 更详细的过滤选项(可以独立过滤几列)。
- 显示有关创建的总对象(包括垃圾收集的对象)的信息。ANTS 仅显示“实时”对象统计信息。这使得分析和调整整体应用程序性能变得更容易(例如,确定在哪些地方不必要地创建了大量不一定泄漏的对象)。
By way of summary, I think ANTS helps you find what's leaking faster while Scitech provides a bit more detail about your overall application memory performance and individual objects once you know what to look at (eg. stack trace on creation). If the stack trace and tracking of undisposed disposable objects was added to ANTS I wouldn't see the need to use anything else.
总而言之,我认为 ANTS 可以帮助您更快地找到泄漏的内容,而 Scitech 会在您知道要查看的内容(例如,创建时的堆栈跟踪)后提供有关整体应用程序内存性能和单个对象的更多详细信息。如果将未处理的一次性对象的堆栈跟踪和跟踪添加到 ANTS,我将不会看到需要使用其他任何东西。
回答by Craig Stuntz
Strange that CLR Profilerisn't mentioned here yet. It's free and works well.
奇怪的是这里还没有提到CLR Profiler。它是免费的并且运行良好。
Beware of the multiple old versions available from Microsoft's own site. As of Nov 2011, the latest version appears to be this one: latest version(alternate link)
请注意 Microsoft 自己的站点提供的多个旧版本。截至 2011 年 11 月,最新版本似乎是这个:最新版本(备用链接)
回答by X-Cubed
If you're feeling really desperate, you can use WinDbgwith the Son-of-Strike library(SOS.DLL) that ships with the .Net framework.
如果您真的感到绝望,可以将WinDbg与.Net 框架附带的 Son-of-Strike 库(SOS.DLL) 一起使用。
回答by annakata
Big fan of JetBrains Profilermyself
我自己是JetBrains Profiler 的忠实粉丝
回答by jfs
.Net Memory Profilerhelped me a lot on my previous project. It's not free but it's very good.
.Net Memory Profiler在我之前的项目中帮助了我很多。它不是免费的,但非常好。
.NET Memory Profiler is a powerful tool for finding memory leaks and optimizing the memory usage in programs written in C#, VB.NET or any other .NET Language.
.NET Memory Profiler 是一个强大的工具,用于在用 C#、VB.NET 或任何其他 .NET 语言编写的程序中查找内存泄漏和优化内存使用。
回答by dmajkic
I second ANTS profiler.
我第二个ANTS profiler。
Beside showing all you need, it will draw simple graph where you can see what takes longest to execute, and what eats memory. When you click on graphp it will show you the coresponding line in your code.
除了显示您需要的所有内容外,它还将绘制简单的图形,您可以在其中查看执行时间最长的内容以及消耗内存的内容。当您单击 graphp 时,它会向您显示代码中的相应行。
And I like litle progress bars drown on code lines which take too long to execute.
我喜欢小进度条淹没在需要很长时间执行的代码行上。
回答by Fabrice
Since everyone's listing the available tools, I thought I'd point you to the complete list of profilers for .NET: http://sharptoolbox.com/categories/profilers-debuggers
由于每个人都列出了可用的工具,我想我会向您指出 .NET 分析器的完整列表:http: //sharptoolbox.com/categories/profilers-debuggers
You'll find there the tools suggested here and all the other ones, each with a short description of what it proposes.
您会在那里找到此处建议的工具以及所有其他工具,每个工具都对其建议的内容进行了简短描述。
回答by Diadistis
I'm currently using ANTS Profiler. It's a very good tool with many profiling detail options and plays well with stand-alone applications, development server and IIS.
我目前正在使用ANTS Profiler。这是一个非常好的工具,具有许多分析细节选项,并且可以很好地与独立应用程序、开发服务器和 IIS 配合使用。

