Is there convenient mem leak check tool in WebKit project?
Purushottam Sholapur 写道:
Hi,
I was facing more problem with memory leak, that too when web pages
have more images.
I could find that div background images, images within div and dynamic
adding of div has some issue.
For that, I have to do three changes (qt embedded +webkit 4.5 on linux)
-------------------------
First :
For image objects, CachedResource reference count was not becoming
zero, even when removeChild is called.
I could find that DocLoader::requestResource() is putting url and
image in hash, which is not cleaned properly.
I have commented following two lines to solve this issue for time
being.(In DocLoader::requestResource())
//m_docResources.set(resource->url(), resource);
//checkCacheObjectStatus(resource);
But browsing looks Ok, I do not see any issue.
Can anybody tell me, what feature might break for this change. What is
the right fix for this.
------------------------
Second:
I had to call GarbageCollector explictly, because JSHTMLImageElement
objects were not getting freed in some cases.
With g_timout_add, I am periodically calling garbagecollector collect
function.
static gboolean callbackGarbageCollector(void* ptr)
{
if(! (JSDOMWindow::commonJSGlobalData()->heap.isBusy()))
{
JSLock lock(false);
JSDOMWindow::commonJSGlobalData()->heap.collect();
}
return TRUE; // infinite ...
}
// Call this function only once ......
__attribute__((visibility("default"))) void startGCTimer(int msec)
{
g_timeout_add(msec /*milli sec */, callbackGarbageCollector, NULL);
}
I assume there will be performce overhead, but any other issue because
of this.
---------------------------
Third:
I had to fix in our web page in javascript code.
1. innerHTML has to set to null ( = '';) after use.
2. div background images have to be set to null once they are removed.
3. For removeChild, We have traverse through the tree and remove each
child and set background image to null.
Here is the code...
function DeleteChildren(node){
if(node){
var cnt = node.childNodes.length;
for(var x = 0; x < cnt; x++){
var childNode = node.childNodes[0];
if(childNode.hasChildNodes()){
DeleteChildren(childNode);
}
node.removeChild(childNode);
childNode=null;
}
node.style.backgroundImage = "";
node=null;
}
}
function removeElement() {
ni = document.getElementById('myDiv');
DeleteChildren(ni);
ni.parentNode.removeChild(ni);
}
---------------------------
If there is something wrong please suggest, I am still a beginner in
qt+webkit.
If people have seen such issues and have some fix, please share...
regards
Purush
------------------------------------------------------------------------
_______________________________________________
webkit-dev mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
_______________________________________________
webkit-dev mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev