Comment #15 on issue 16821 by [email protected]: Memory leak
http://code.google.com/p/chromium/issues/detail?id=16821

So I think I know it all now.

There are two sources of global handles (after the 1st loop):

1) persistent handles for functions which where setTimeout'ed (see  
DisplayAuto
function in leak.htm);  the relevant parts of the code:

ScheduledAction* action = new  
ScheduledAction(V8Proxy::context(imp->frame()),
v8::Handle<v8::Function>::Cast(function), paramCount, params);

(ln. 116 of V8DOMWindowCustom.cpp).

and

ScheduledAction::ScheduledAction(v8::Handle<v8::Context> context,
v8::Handle<v8::Function> func, int argc, v8::Handle<v8::Value> argv[])
     : m_context(context)
     , m_code(String(), KURL(), 0)
{
     m_function = v8::Persistent<v8::Function>::New(func);

In this particular case we pass the same function, but create a new  
persistent handle
for each page.

2) [and that's more important]: actually we crate a lots of new nodes due  
to one
nasty thing: in Fetch div.firstChild HTML is updated.  As WebKit doesn't  
check if
HTML fragments are the same, it just reinitializes  
div.firstChild.firstChild node.
So on each iteration another WebKit Node is created and none is released.

Just to check: either comment update of innerHTML or do not lookup second  
firstChild
(that is: dummy = div.firstChild)---with those changes this leak.htm runs  
ways longer
on my box even though it still leaks due to creation of global handles.

Now to how to fix it.  We could adapt approach used in JSC and partially in  
V8/DOM
bindings: associate an external cost (e.g. each global handle would include  
roughly
the size of WebKit node it wraps), then this cost grows beyond some limit,  
let's GC.

Another approach, notably easier and less intrusive, could be to check on  
global
handle creation several things like total number of global handles, amount  
of
allocated data in the heap, last gc time, etc. and force GC from time to  
time.

My main concern would be performance implications.

Let me think one night and I would appreciate any other ideas/discussion.   
And I'm
pointing out this bug to the rest of V8 team in hope get some cool ideas.

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
Automated mail from issue updates at http://crbug.com/
Subscription options: http://groups.google.com/group/chromium-bugs
-~----------~----~----~----~------~----~------~--~---

Reply via email to