我写了一个基于本教程的BHO:http://www.codeproject.com/KB/cs/Attach_BHO_with_C_.aspx
我的GetSite和SetSite与教程列表相同。我正在添加/删除一个OnDocumentComplete处理程序,并在IObjectWithSite SetSite函数中分配SHDocVW.WebBrowser webBrowser
出于调试目的,我删除了除基本功能之外的所有功能。这是我的OnDocumentComplete处理程序。
public void OnDocumentComplete(object pDisp, ref object URL)
{
if (true)
{
HTMLDocument document;
document = (HTMLDocument)webBrowser.Document;
/*need to do some stuff here to the doc*/
//then free up script references somehow?
}
return;
}当我将我的VS2008调试器附加到IE实例时,我注意到所有加载的.js在各自的窗口/选项卡关闭后仍然存在。如果我将OnDocumentComplete中的条件设置为false (或禁用我的BHO),泄漏就会消失。我需要在mshtml.HTMLDocument上做更多的清理吗?谢谢!
发布于 2010-07-14 05:39:53
试试calling Marshal.ReleaseCOMObject(document)。
https://stackoverflow.com/questions/3241744
复制相似问题