[webkit-qt] Memory Leak in QtWebKit

chen mihua chenmh at cn.fujitsu.com
Wed Feb 29 17:57:13 PST 2012


Dear Alexis

Thanks for your reply.

It is correct that OS will free all allocated memory when the program is closed, however, this will
not help us, because we want our program to run continuously after the device is powered on.
The program has multi tab feature, so construction and destruction of webview objects will happen
frequently in our scenario.

So it would be a problem if memory leak happens after every destruction of webview object.
Don't you agree this?

You have mentioned that it is faster to free leaking memory by OS , but in my view a program is
responsible for doing cleanup work by itself and never depends OS to do it.
So I want to figure out the real reason why webkit is designed like this?  Can you provide some
information about this?

Best Regards

Eric Chen


On 2012年02月29日 19:17, Alexis Menard wrote:
> On Wed, Feb 29, 2012 at 12:53 AM, 陳敏華<chenmh at cn.fujitsu.com>  wrote:
>> Dear all
>>
>> I'd like to ask you question about memory leak in Webkit. Currently, I am using
>> QtWebkit self contained in Qt 4.8.0, and my test application is like follows:
>>
>> int main(int argc, char *argv[])
>> {
>>     QApplication a(argc, argv);
>>     QWebView* view = new QWebView();
>>     view->load(QUrl("http://www.baidu.com"));
>>     view->show();
>>     a.exec();
>>     delete view;
>>     return 0;
>> }
>>
>> As you know, Webkit provide RefCountedLeakCounter class to detect memory leak. When I run this test application in debug mode, I have noticed that many WebCoreNodes and CachedResource have leaked. This leak could be a big problem because we want to make use of WebKit in embedded device.
> But when the program is closed aren't the memory allocated to him
> freed by the OS?
>
>> So, I'd like to ask you all whether this memory leak real or not? I just can't believe Webkit would leak memory in such a simple test, or if Webkit provides some other mechanism to ensure memory will not be leaked, please tell me.
> It happens that sometimes leaking on exit is not very bad as the OS
> will free the memory for you anyway. In some scenarios it is faster to
> do so...Now I haven't investigate myself but I know it sometimes
> happens. In modern OS it's not a problem, maybe on yours it is fine
> too. You have to check.
>
>> Can anyone provide some information about this problem? I really appreciate your help.
>>
>> Best Regards
>>
>> Eric Chen
>> ---------------------------------------------------
>> Chen Minhua
>> Development Dept.III
>> Nanjing Fujitsu Nanda Software Tech. Co., Ltd.(FNST)
>> No. 6 Wenzhu Road, Nanjing, 210012, China
>> TEL: 86630566-615
>> COINS: 79955-615
>> FAX: 83317685
>> MAIL: chenmh at cn.fujitsu.com
>> ---------------------------------------------------
>>
>>
>>
>> _______________________________________________
>> webkit-qt mailing list
>> webkit-qt at lists.webkit.org
>> http://lists.webkit.org/mailman/listinfo.cgi/webkit-qt
>
>



More information about the webkit-qt mailing list