外部触发.NET垃圾回收 [英] Triggering a .NET garbage collection externally

查看:120
本文介绍了外部触发.NET垃圾回收的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有一种在另一个进程或WinDBG内部的.NET进程中触发垃圾收集的方法?有一个受管理的调试助手强制收集当您移动本机/管理边界时, AQTime 似乎有按钮,表明它是这样做的,但我找不到任何有关如何做的文件。

解决方案

John Cocktoastan的答案是使用GC.Collect如果有的话,Visual Studio是最好的选择。



我仍然找不到在WinDBG下实际执行集合的替代方法,但是要回到多少记忆可以回收吗? (见我对John的回答的评论)我认为使用脚本( PowerDBG )有另一种选择)通过某些组合搜索!DumpHeap和!GCRoot找到无根的句柄,并总共使用的空间(基本上模拟GC将使用调试器执行的算法)。但是,由于这个想法,我没有一个这样的错误,所以没有试图写代码来做。


Is there a way to trigger a garbage collection in a .NET process from another process or from inside WinDBG?

There are the Managed Debugging Assistants that force a collection as you move across a native/managed boundary, and AQTime seems to have button that suggests it does this, but I can't find any documentation on how to do it.

解决方案

John Cocktoastan's answer to use GC.Collect when in Visual Studio is the best option if there.

I still can't find an alternative to actually do the collection under WinDBG but taking a step back to problem of "How much memory is reclaimable?" (see my comment to John's answer) I think there is an alternative by using a scripted (PowerDBG?) search via some combination of !DumpHeap and !GCRoot to find the non-rooted handles and total the space used (basically emulate the algorithm that the GC would do using the debugger). But since thinking of this I haven't had one of these bugs so haven't tried to write the code to do it.

这篇关于外部触发.NET垃圾回收的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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