如何使用转储文件诊断内存泄漏? [英] How do I use a dump file to diagnose a memory leak?

查看:415
本文介绍了如何使用转储文件诊断内存泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个约80 MB的一个正常的专用工作集的.NET服务。在最近的一次负荷测试,该过程达到3.5 GB的内存使用情况造成整个机器要低于物理存储器(3.9 4的采用GB),和负载测试后停止的存储器未释放长。使用任务管理器,我把这个过程的转储文件,并在Visual Studio 2010 SP1中打开它,我可以在其上启动调试。

我如何诊断内存问题?我有dotTrace内存3.x的在我手上,它支持内存分析的转储文件?如果没有,将内存分析的Visual Studio 2010的premium帮助功能(我现在有专业的)?可以WinDbg的帮助?

  

更新:新的的Visual Studio 2013旗舰版的现在可以在本机使用诊断转储文件存储的问题。请参阅<一href="http://blogs.msdn.com/b/visualstudioalm/archive/2013/06/20/using-visual-studio-2013-to-diagnose-net-memory-issues-in-production.aspx">this博客文章了解更多详情。

解决方案

安装的WinDbg。你需要确保你得到正确的版本x86或x64取决于你的转储。这里是一个直接链接到<一个href="http://download.microsoft.com/download/A/6/A/A6AC035D-DA3F-4F0C-ADA4-37C8E5D34E3D/setup/WinSDKDebuggingTools/dbg_x86.msi">download用于x86。

在这一点,你需要确保你把正确的转储。您可以使用任务管理器来创建转储文件(右键单击程序 - >创建转储文件)。 如果你在64位和你的过程是86使用任务管理器(C:\ WINDOWS \ Syswow64资料\的TaskMgr.exe)的32位版本,以转储文件。见服用转储文件,如:我的文章信息,如果你在XP并需要使用WinDbg创建转储文件。

警告有一个相当陡峭的学习曲线,这里所描述的东西可能不完全工作,所以回来的任何问题。

我在你使用.NET4给你可以打开Visual Studio中的转储假设。这里有一个的非常的快速指南,以帮助您与您的dmp文件:

1)运行的WinDbg,一套符号路径(文件 - >符号搜索路径),以

  

SRV * C:\符号* http://msdl.microsoft.com/download/symbols

2)打开崩溃转储或者拖动.DMP文件到WinDbg的。

3)输入这个到命令窗口

  .loadby SOS CLR
 

(仅供参考,用于.NET 2,命令应 .loadby索斯mscorwks

4),然后键入此

 !dumpheap -stat
 

,它列出对象及其计数的类型。 看起来是这样的:

您必须分析这个在您的应用程序的情况下,看看会出现什么不同寻常。

目前的的多WinDbg的,谷歌是你的朋友。

I have a .NET service with a normal private working set of about 80 MB. During a recent load test, the process reached 3.5 GB memory usage causing the whole machine to be low on physical memory (3.9 of 4 GB used), and the memory was not released long after the load test was stopped. Using task manager, I took a dump file of the process and opened it in Visual Studio 2010 SP1, and I am able to start debugging on it.

How do I diagnose the memory issue? I have dotTrace Memory 3.x at my disposal, does it support memory profiling on dump files? If not, will the memory profiling features of Visual Studio 2010 Premium help (I currently have Professional)? Can WinDbg help?

UPDATE: The new Visual Studio 2013 Ultimate can now natively diagnose memory issues using dump files. See this blog post for more details.

解决方案

Install WinDbg. You need to make sure you get the correct version x86 or x64 depending on your dump. Here is a direct link to the download for x86.

On that, you need to ensure you took the correct dump. You can use Task Manager to create the dump file (right click on process -> Create Dump File). If you're on 64bit and your process is x86 use the 32bit version of Task Manager (C:\Windows\SysWOW64\taskmgr.exe) to take the dump file. See my article for more info on taking dump files, eg if you're on XP and need to use windbg to create the dump file.

warning there's a fairly steep learning curve and things might not work exactly as described here so come back with any issues.

I'm assuming you're using .NET4 given you can open the dump in Visual Studio. Here's a very quick guide to help you work with your dmp file:

1) Run WinDbg, set symbols path (File -> Symbol Search Path) to

SRV*c:\symbols*http://msdl.microsoft.com/download/symbols

2) Open Crash dump or drag your .DMP file onto WinDbg.

3)type this into the command window

.loadby sos clr

(FYI, for .NET 2, the command should be .loadby sos mscorwks)

4) then type this

!dumpheap -stat

which lists the type of objects and their count. looks something like this:

You will have to analyze this in the context of your application and see if anything appears unusual.

There is much more to windbg, google is your friend.

这篇关于如何使用转储文件诊断内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆