Opened 6 years ago

Last modified 2 years ago

#17054 assigned defect

Stateful retains callback of removed handle

Reported by: Per Zimmerman Owned by: Kris Zyp
Priority: undecided Milestone: 1.15
Component: Core Version: 1.8.3
Keywords: Cc:
Blocked By: Blocking:

Description

The watch handle retains the observer callback. If the callback is a hitched callback, the scope will also be retained, ie any Stateful that lives longer than it's observer will keep it's observers in memory even though the observers removed it's watch handles.

I have made to example pages. They both have an observer with a 50M long string to make it easier to spot when the observer can't be released.

Example with dojo Stateful http://www.dentaku.com/demo/dojo183/statefulretain/stateful-dojo.html

Example with custom Stateful http://www.dentaku.com/demo/dojo183/statefulretain/stateful-custom.html

Proposed fix is to null the callback and reset the handle remove function:

handle.unwatch = handle.remove = function(){
	var index = array.indexOf(propertyCallbacks, callback);
	if(index > -1){
		propertyCallbacks.splice(index, 1);
	}
	
	// FIX:
	// no need to ref callback in closure, let's bind an empty functionn
	// as we already removed it from the callbacks
	callback = null;
	handle.unwatch = handle.remove = function(){};
	handle = null;
};

Change History (3)

comment:1 Changed 6 years ago by bill

Component: GeneralCore
Owner: set to Kris Zyp
Status: newassigned

comment:2 Changed 3 years ago by dylan

Milestone: tbd1.12

Will review for 1.12, to determine if this is still an issue and if so, if we can fix it without introducing other issues.

comment:3 Changed 2 years ago by dylan

Milestone: 1.131.15

Ticket planning... move current 1.13 tickets out to 1.15 to make it easier to move tickets into the 1.13 milestone.

Note: See TracTickets for help on using tickets.