I run this script in Google Chrome using the Chrome Task Manager to monitor memory usage:
<html>
<head>
<title>Test Page</title>
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<script type="text/javascript">
var count = 0;
function incrementContent() {
$("#content").text(count);
count++;
setTimeout(incrementContent, 5);
}
</script>
</head>
<body onload="incrementContent()">
<div id="content">
</div>
</body>
</html>
Memory usage will constantly increase to a maximum of ~ 31,000 K, and then will remain at that level.
As far as I can see, the loop should just overwrite the same element in the document.
What causes the allocation of a large amount of memory?
Using IE 8, I do not see a noticeable increase in memory usage while the script is running.
Using Firefox 3.5.3 uses a several megabyte increase cycle for a minute or so, and then drops the baseline.
source
share