Instances referenced by 'bound_this' only are not garbage collected

Viewed 2102

I have a question regarding garbage-collection in google chrome (Version 20.0.1132.47, Ubuntu 11.04 64bit).

While comparing heap-dumps and checking for memory-leaks, I discovered some instances, that are never cleaned up. Normally this behaviour can be tracked down to a programmer-error, but in this case I'm rather clueless..

Take a look at the following screenshot Screenshot of heap-dump showing an instance (child) referenced only by 'bound_this'

The instance 'child @610739' is referenced only by 'bound_this' instances that belong to functions of the child-instance itself. So to my understanding, the child-instance should be garbage-collected, as the only other reference keeping hold of it is the child-instance itself (through the 'bound_this' functions).

I'm using underscore.js' 'bindAll' utility function (underscore.js#bindAll) that maps to the 'native_bind' function of chrome (ECMA Script wiki on bound_this)

Am I missing something obvious here and if so, could someone explain what's keeping these instances alive?

UPDATE:
In the meanwhile I tested the same application in chrominium (18.0.1025.168 (Developer Build 134367 Linux) Ubuntu 11.10) which does not show these dangling instances..

UPDATE 2:
Following Esailijas hint to provide a jsfiddle snippet, I created one (http://jsfiddle.net/8gSTR/1/) that mimics what I'm basically doing. Running this fiddle unfortunately does not show the misbehaviour I'm experiencing in my application. A heap-dump taken while 'a'-instances are still referenced looks kind of similar though despite of the reference from the window.o array which keeps the instances alive: Heap-dump taken during execution of jsfiddle mentioned above

As such a reference is missing in my case (screenshot 1) I don't know what keeps chrome from freeing these instances...

UPDATE 3:
Followed loislos advice to enable hidden properties. The result (with one of the branches expanded) can be seen in the following screenshot but it does not take me any further. Heap-dump with hidden properties enabled

3 Answers
Related