javascript - Clearing memory references in closures -


i have question how closures work in relation garbage collection. have created javascript application seems continually adding objects don't cleaned when create new project. in code application clears out references newly created objects , make sure unbind events , dispose them. when in chrome heap profiler see:

enter image description here

when click on references of objects can see there pointers objects in jquery proxy function. (specifically variable 'context')

from can see, proxy function creates closure , closure has reference viewport when constructed. how i'm using proxies in viewport3d:

//in constructor of viewport3d this.keydownproxy = jquery.proxy( this.onkeydown, ); jquery(document).on( "keydown", this.keydownproxy ); 

...

//in dispose method of viewport jquery(document).off( "keydown", this.keydownproxy ); this.keydownproxy = null; 

so can see removing events nullifying proxy closure reference exists.

so why viewport3d still exist in memory after events have been removed , proxies nullified know section of code because when comment out created proxies, class garbage collected.

if because there loose pointer somewhere else keeping alive, there other way can see coming in chrome?

thanks guidance can provide.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -