Opened 13 years ago

Closed 12 years ago

Last modified 10 years ago

#1041 closed defect (fixed)

General Widget Memory Leak

Reported by: tonyissakov@… Owned by: alex
Priority: high Milestone: 0.9
Component: Widgets Version: 0.3
Keywords: memory leak widget Cc:
Blocked By: Blocking:

Description

Following on from ticket #493 memory leaks in firefox I believe I've narrowed down the leak to the process of auto linking event functions to html placeholders. An example can be found as in #493 with the dialog widget and the event links:

"dojoOnFocus="trapTabs" dojoOnBlur="clearTrap"

Still present in nightly builds. http://archive.dojotoolkit.org/dojo-2006-06-27/tests/widget/test_Dialog.html

file: srcwidgetDomWidget.js

dojo.widget.attachTemplateNodes Line 203

var tf = function(){
	var ntf = new String(thisFunc);
	return function(evt){
	if(_this[ntf]){
		_this[ntf](dojo.event.browser.fixEvent(evt, this));}
	};
 }();
dojo.event.browser.addListener(baseNode, tevt, tf, false, true);

This code in effect creates a closure for every instance of connection point and there is a leak for each.

One possible solution is to use dojo.event.connect to link the function to the node and event rather than addListener or even better rewrite addListener. My local tests show this to work but am unsure of any side effects.

Change History (3)

comment:1 Changed 13 years ago by TonyIssakov@…

Following the above I did a quick test:

file: srceventrowser.js dojo.event.browser.addListener

remove the usage of node.addEventListener in the below code and the above leak reports under firefox dissapear.

if(node.addEventListener){ 
	node.addEventListener(evtName.substr(2), newfp, capture);			
	return newfp;
}else{
	if(typeof node[evtName] == "function" ){
		var oldEvt = node[evtName];
		node[evtName] = function(e){
			oldEvt(e);
			return newfp(e);
		}
	}else{
		node[evtName]=newfp;
	}
	if(dojo.render.html.ie){
		this.addClobberNodeAttrs(node, [evtName]);
	}
	return newfp;
}

comment:2 Changed 13 years ago by dylan

Milestone: 0.5
Owner: changed from anonymous to alex

comment:3 Changed 12 years ago by bill

Resolution: fixed
Status: newclosed

All that code is gone in 0.9, and this problem should be fixed; please test again and file new bugs if there are still leaks; thanks!

Note: See TracTickets for help on using tickets.