Hi,

I am doing so performance testing with javascript and jquery and came
across a strange issue. The following code works fine in IE 7, I can
refresh multiple times. When I load the page the first time in firefox
3.0.6 everything is fine, but when I do a refresh firefox locks for
about 2 minutes, cpu usage is 100% and memory usage has a peak of
~300MB and avarage of ~170MB. The problem occurs when the click event
is attached to the span elements, if I put that part in comment
firefox allows multiple refreshes.

<html>
<head>
<title></title>
<script language="javascript" type="text/javascript"
src="jquery-1.3.1.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function()
{
    var dateBegin = new Date();
    var dateEnd = null;

    var arr = new Array();
    var index = 0;
    arr[index++] = "<table>";
    var tr = null;
    var td = null;
    var span = null;

    for(var i = 0; i < 500; i++)
    {
        arr[index++] = "<tr>";

        for(var j = 0; j < 10; j++)
        {
            arr[index++] = "<td><span>" + (i + j) + "</span></td>";
        }

        arr[index++] = "</tr>";
    }

    arr[index] = "</table>";

    $("#content").html(arr.join(""));
    alert("content");

    dateBegin = new Date();
    $("span").click(function()
    {
       alert($(this).html());
    });
    dateEnd = new Date();

    alert(dateEnd - dateBegin);
});
</script>
</head>
<body>
<div id="content"></div>
</body>
</html>

Reply via email to