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

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

问题描述

有没有办法从另外的进程或内部的WinDBG触发垃圾收集在.NET程序?

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

有托管调试助手,强制的集合作为你整个本地/托管边界移动, AQTime 似乎有按钮表明它这样做,但我不能找到如何做的文档。

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.

推荐答案

约翰Cocktoastan的答案,所以GC.Collect使用时,在Visual Studio中是最好的选择,如果有。

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

我仍然无法找到一种替代实际做的WinDBG下的集合,但退后一步来的问题多少内存是可回收? (见我的评论约翰的回答)我觉得这是通过使用脚本替代( PowerDBG ?)通过!DumpHeap和!GCRoot的组合搜索,找到了无根手柄和总使用的空间(基本模拟算法的GC会使用调试器做的)。但是,由于这种思维,我还没有这些缺陷所以没有尝试过写code一做吧。

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天全站免登陆