如何使用WinDbg追查.NET内存不足异常? [英] How to use WinDBG to track down .net out of memory exceptions?

查看:337
本文介绍了如何使用WinDbg追查.NET内存不足异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要跟踪的内存不足(OOM)异常的.NET应用程序的原因。使用性能监视器,采用相对较低的内存(500-700mb)时,应用程序崩溃与OOM,所以我假设某种形式的堆碎片的。

I need to track down the reason for out of memory (OOM) exceptions in a .NET application. Using perfmon, the app crashes with an OOM when using relatively low memory (500-700mb), so I'm assuming some sort of heap fragmentation.

研究后,它看起来就像WinDBG的是用来追踪这类问题下来的工具。我已经成立了DebugDiag资料正在运行的进程在服务器上。我也设法从DebugDiag资料加载转储到WinDBG的,挂钩符号服务器和我自己的私人符号文件,这一切似乎工作 - 我可以运行像命令clrstack !dumpheap -stat ,我会看到我的类名上市。

After researching it looks like WinDBG is the tool to use to track this kind of problem down. I've set up DebugDiag on the server running the processes. I've also managed to load the dump from DebugDiag into WinDBG, hook up the symbol server and my own private symbol files and it all seems to work - I can run commands like !clrstack and !dumpheap -stat and I'll see my class names listed.

这个问题我现在已经是我不知道如何处理跟踪那里的碎片化的问题。 WinDGB有很多命令有很多不同的标志和选项,我不知道我应该使用哪些。我无法追查做什么或者一个很好的教程 - 大部分都是围绕让WinDBG的启动和运行非常基本的

The problem I have now is I don't know how to approach the problem of tracking down where the fragmentation is. WinDGB has a lot of commands with a lot of different flags and options and I'm not sure which ones I should be using. I couldn't track down a good tutorial on what to do either - most are really basic around getting WinDBG up and running.

可能有人点我在正确的方向?

Could someone point me in the right direction?

推荐答案

下面是我使用的决定有关.NET OutOfMemoryExceptions图:

Here's the graph that I use for deciding about .NET OutOfMemoryExceptions:

对于!U 的一部分,我知道两个选项至今。首先是创建对象的一个​​大阵。请参见如何识别数组类型了解详细信息。二是直接抛出一个OutOfMemoryException,你会找出这样的:

For the !u part, I know two options so far. The first is the creation of a big array of objects. See How to identify array type for details. The second is throwing an OutOfMemoryException directly, which you would identify like this:

0:000> .symfix d:\debug\symbols

0:000> .reload

0:000> ~#s

0:000> .loadby sos mscorwks; *** Use clr if .NET4

0:000> !pe
Exception object: 025d07d8
Exception type: System.OutOfMemoryException
Message: Nicht genügend Speicher verfügbar, um das Programm weiter auszuführen.
InnerException: <none>
StackTrace (generated):
    SP       IP       Function
    0024EC90 004F008D OOM1!OOM1.Program.Main()+0x1d

0:000> !u 004F008D 
Normal JIT generated code
OOM1.Program.Main()
Begin 004f0070, size 1e
004f0070 50              push    eax
004f0071 b96c0fcb78      mov     ecx,offset mscorlib_ni+0x270f6c (78cb0f6c) (MT: System.OutOfMemoryException)
004f0076 e8a11ff1ff      call    0040201c (JitHelp: CORINFO_HELP_NEWSFAST)
004f007b 890424          mov     dword ptr [esp],eax
004f007e 8bc8            mov     ecx,eax
004f0080 e8f314c078      call    mscorlib_ni+0x6b1578 (790f1578) (System.OutOfMemoryException..ctor(), mdToken: 0600036a)
004f0085 8b0c24          mov     ecx,dword ptr [esp]
004f0088 e84a615179      call    mscorwks!JIT_Throw (79a061d7)
>>> 004f008d cc              int     3

要通话调用System.OutOfMemoryException..ctor()在C#中的新OutOfMemoryException异常()通话mscorwks!JIT_Throw 抛出关键字。

The call to call System.OutOfMemoryException..ctor() is a new OutOfMemoryException() in C# and call mscorwks!JIT_Throw is the throw keyword.

这篇关于如何使用WinDbg追查.NET内存不足异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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