PDA

View Full Version : Memory Leak when using createDelegate : what's wrong with my usage ?



Pyja
1 Dec 2009, 5:58 AM
Hi,

I see something that boring me :

When using create delegate in an action handler, when destroying toolbar, i see that not all are release (sIEve testing)
var anAction = new Ext.Action({
text : 'Search',
handler : function(){
}.createDelegate(this)
});

If i remove the createDelegate, all are OK

What's wrong with my createDelegate usage ?

Animal
1 Dec 2009, 7:36 AM
Don't use it.

Use the scope option.

VinylFox
1 Dec 2009, 7:49 AM
Just to elaborate with an example...


var anAction = new Ext.Action({
text : 'Search',
handler : function(){
// scope is your 'this' in here
},
scope: this
});

Pyja
1 Dec 2009, 7:59 AM
Problem still remaining...
if i set the scope, still memory leak detected under sIEve.
if i remove the 'scope : this' setting, no more memory leak in sIEve

Any idea ?

CrazyEnigma
1 Dec 2009, 7:59 AM
I saw this example in another thread, does this apply as well. Or how would I apply the scope in this case.



google.earth.createInstance(this.body.dom, this.onEarthReady.createDelegate(this), this.onEarthFailed.createDelegate(this));

Animal
1 Dec 2009, 8:46 AM
There have been lots of memory fixes for 3.1 let's see if that fixes it for you.