JavaScript memory leaks - test

Intro

Explanation

Leaks one object per closure per element.

window.onload = init;

function init()
{
	// Start timing
	var T1 = (new Date()).getTime();

	createLinks();
	var x = document.getElementsByTagName('a');
	for (var i=0;i<x.length;i++)
	{
		assignListener(x[i]);
	}

	// How long did that take?
	alert("it took " + ((new Date()).getTime() - T1) / 1000 + " seconds to render this\r\nHit F5 and see what happens to the render time.");
}

function assignListener(p_e)
{
	p_e.onclick = function ()
	{
		p_e.firstChild.nodeValue = ' Clicked! - ';
	}
}

Test