Opened 16 years ago

Closed 15 years ago

Last modified 12 years ago

#1041 closed defect (fixed)

General Widget Memory Leak

Reported by: [email protected] Owned by: alex
Priority: high Milestone: 0.9
Component: Widgets Version: 0.3
Keywords: memory leak widget Cc:
Blocked By: Blocking:


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.

file: srcwidgetDomWidget.js

dojo.widget.attachTemplateNodes Line 203

var tf = function(){
	var ntf = new String(thisFunc);
	return function(evt){
		_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 16 years ago by [email protected]

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.

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

comment:2 Changed 16 years ago by dylan

Milestone: 0.5
Owner: changed from anonymous to alex

comment:3 Changed 15 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.