View Full Version : Observable.clearmanagedListeners has a memory leak

5 Dec 2011, 11:10 AM
Sencha Touch version tested:


Platform tested against:

It doesn't matter, it isn't a layout / rendering problem.


The clearManagedListeners should reset the instance property managedListeners to prevent memory leaks

Steps to reproduce the problem:

render a component
add a managed listener
console.log out managedListeners.length // 1
call clearManagedListeners
console.log out manageListeners.length // 1

The result that was expected:

clearManagedListeners should clear the internal array

The result that occurs instead:

the array is never cleared

Debugging already done:

I did an override on the function to fix the issue. It's a typo( this.managedListener rather that this.managedListener*s* )

Possible fix:

clearManagedListeners: function() {
var managedListeners = this.managedListeners || [],
ln = managedListeners.length,
i, managedListener;

for (i = 0; i < ln; i++) {
managedListener = managedListeners[i];
managedListener.item.un(managedListener.ename, managedListener.fn, managedListener.scope);

this.managedListeners = [];

5 Dec 2011, 2:12 PM
Simple typo.... it has this.managedListener = []; but should be this.managedListeners = [];