October 20, 2005
Open Windows Task Manager (Ctrl-Shift-Esc) activate Performance tab. You will see the memory rising slightly.
Code:
var count = 0;
function stressTest()
{
// Find and clear the container.
var container = document.getElementById("my-element");
container.innerHTML = "";
// Create 10 clickable P's.
for (var i = 0; i < 10; i++)
{
var newElement = document.createElement("p");
newElement.innerHTML = "Element #" + count++;
container.appendChild(newElement);
newElement.attachEvent("onmousedown", downHandler.closure(newElement));
}
// Repeat, and give the browser a change to execute events.
setTimeout(stressTest);
}
function downHandler()
{
alert("Mouse down on: " + this.innerHTML);
}