Delphi TWebBrowser内存泄漏 [英] Delphi TWebBrowser Memory Leak

查看:292
本文介绍了Delphi TWebBrowser内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序使用加载网页的TWebBrowser。问题是,在关闭包含TWebBrowser的表单之后,所使用的内存不会被释放。如果我打开和关闭窗体,内存就会不断增加。



查看有关调用SetProcessWorkingSetSize()或CoFreeUnusedLibrariesEx()的一些帖子来解决这个问题,但我不知道这些是否是正确的解决方案。 >

任何想法如何释放TWebBrowser使用的内存?

解决方案

QC#106829 描述了TWebBrowser内存泄漏的一个可能的原因。访问文档(以及通过 TOleControl.GetIDispatchProp TOleControl.GetIUnknownProp实现的任何其他属性)导致泄漏,因为它调用AddRef而不会调用Release。作为解决方法,您可以手动调用Release,或者您可以修补VCL(看到这里),或者你可以避免有问题的属性(例如,使用 browser.DefaultInterface.Document 而不是 browser.Document )。


My application uses a TWebBrowser that loads a webpage. The problem is, after closing the form containing the TWebBrowser, the memory used is not freed. If I open and close the form, the memory just keeps on increasing.

Saw some post regarding calling SetProcessWorkingSetSize() or CoFreeUnusedLibrariesEx() to solve this issue, but I'm not sure if any of these are the correct solution.

Any idea how to free the memory used by TWebBrowser?

解决方案

QC#106829 describes one possible cause of memory leaks with TWebBrowser. Accessing Document (and any other properties that are implemented via TOleControl.GetIDispatchProp or TOleControl.GetIUnknownProp) causes leaks because it calls AddRef without ever calling Release. As a workaround, you can manually call Release, or you can patch the VCL (see here), or you can avoid the problematic properties (for example, by using browser.DefaultInterface.Document instead of browser.Document).

这篇关于Delphi TWebBrowser内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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