!DumpHeap - 可以禁用GC的警告?DumpHeap、GC

2023-09-06 10:13:02 作者:无所谓的魅惑

我有一个NT服务全过程中转储(使用C#/。NET 4.5.2实现)这是在GC周期的中间。当我将其加载到WinDbg中,并尝试运行!DumpHeap -stat (或任何其他变种 DumpHeap ),我得到这样的警告:

I have a full process dump from an NT service (implemented using C# / .NET 4.5.2) that's in the middle of a GC cycle. When I load it into WinDbg and try to run !DumpHeap -stat (or any other variant of DumpHeap), I get this warning:

在垃圾收集器的数据结构不为遍历一个有效的状态。它无论是在规划阶段,其中的物体正在移动周围,或者我们是在GC堆的初始化或关闭。相关的命令来显示,发现或运动的物体,以及GC堆段可能无法正常工作。 !dumpheap和!verifyheap可能会错误地抱怨堆一致性错误的。

The garbage collector data structures are not in a valid state for traversal. It is either in the "plan phase," where objects are being moved around, or we are at the initialization or shutdown of the gc heap. Commands related to displaying, finding or traversing objects as well as gc heap segments may not work properly. !dumpheap and !verifyheap may incorrectly complain of heap consistency errors.

不幸的是,我不能(容易)得到一个干净的内存转储GC之外(我当然不知道,当它发生,我需要一些管理规模的转储 - 这个过程我看存在内存泄漏问题,达到18 GB有时;这是如此之大,大部分堆查找接管WinDbg中40分钟)

Unfortunately, I cannot (easily) get a clean memory dump outside of GC (I obviously don't know when it happens and I need a dump of some manageable size - the process I'm looking at leaks memory and reaches 18 GB sometimes; this is so big that most heap lookups take over 40 minutes in WinDbg.)

此警告信息显示出来,甚至当我使用 -short 参数,只生成目标地址(输入成一个WinDbg的宏) - 警告不幸的话消息被传递作为输入参数给宏和宏吹。 (宏这个问题的一个变种,我试图运行!GCRoot 对大量对象实例。)

This warning message shows up even when I use the -short parameter to only generate object addresses (to input them into a WinDbg macro) - unfortunately the words of the warning message are passed as input parameters to the macro and the macros blows up. (The macro is a variant of this question and I'm trying to run !GCRoot on a large number of object instances.)

有没有一种方法来禁用WinDbg中此警告消息? ( DumpHeap 是SOS的一部分,所以我想它需要被禁止在那里,如果可能的话。)

Is there a way to disable this warning message in WinDbg? (DumpHeap is part of SOS, so I guess it needs to be disabled there, if possible.)

修改:要清楚,我得到有用的输出从 DumpHeap 和其它命令(这似乎大多是一致的),它只是所有输出始于上述警告,即使使用 -short 。这意味着,我不能喂输出到其他的命令。

Edit: to make it clear, I get useful output from DumpHeap and other commands (which seem mostly consistent), it's just that all output begins with the above warning, even when using -short. This means that I cannot fed the output into other commands.

推荐答案

我明白这是一个可惜的是 -short 输出包含的信息。恕我直言消息不能被禁用。

Your question

I understand it is a pity that the -short output contains that message. IMHO the message cannot be disabled.

您可以使用 pykd(codePLEX)过滤文本。你需要的 dbgCommand() 功能发出!dumpheap 命令。你会得到一个字符串命令的输出,然后你可以过滤文本。接下来,您可以在文本推回用 DPRINT()

You can use pykd (Codeplex) to filter the text. You'd need the dbgCommand() function to issue the !dumpheap command. You'll get back a string with the output of the command and you can then filter the text. Next you could push the text back to the debugger with dprint().

也许你想尝试taking转储时,.NET不是一个垃圾收集的中间。

加快东西:

sosex 有一个!BHI 命令来建立一个堆指数。 heapdump 攻击面利用

netext 有一个!WINDEX 命令来建立一个堆索引。它甚至有类似于命令dumpheap 可在 .foreach 的方式来使用(从网站)! sosex has a !bhi command to build a heap index.

netext has a !windex command to build a heap index. It even has a command similar to !dumpheap which can be used in the .foreach fashion (from the website):

.foreach({$addr} {!windex -short -type *.HttpRequest}){!wselect _url.m_String from {$addr} }

PyKd:当你在这,你也可以重写 .foreach 循环Python和执行在Python的一部分,以及,让您根据自己的内容等进行过滤对象,所以你可能会得到一些时间回用更直观的脚本语言。

PyKd: While you're at it, you might also rewrite the .foreach loop in Python and do the !do part in Python as well, allowing you to filter objects based on their content etc. so you might get some time back by using a more intuitive scripting language.