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?
Basically the policy in WebKit is _not_ to free global objects ever
(caches for example). One reason for this is to make shutdown faster.
However, as long as you actually use WebKit (i.e. creating new views)
you don't need to worry about that. These resources are not tied to a
particular view, so a new view can reuse them. In order to purge the
data that has been cached for the old page you can use
QWebSettings::clearMemoryCaches(), that should actually free everything
that cannot be reused in the new page. Another thing you can do is
forcing a JS garbage collection - but in this case you need to build
your own WebKit since afaik there is no public API for this. Hope that
helps.
cheers!
-kbalazs
Best Regards
Eric Chen
On 2012年02月29日 19:17, Alexis Menard wrote:
On Wed, Feb 29, 2012 at 12:53 AM, 陳敏華<[email protected]> 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: [email protected]
---------------------------------------------------
_______________________________________________
webkit-qt mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-qt
_______________________________________________
webkit-qt mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-qt
_______________________________________________
webkit-qt mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-qt