I have this html page running on IE8 and it crashes every 3-4 days. Is it something wrong with the use of settimeout here? I also used proxy and it did not help. But it can run on Firefox with no issue.
<html>
<head> <meta charset="utf-8">
<title>jQuery.proxy demo without proxy</title>
<script src="C:\Documents and Settings\xc91977\Desktop\JqueryLib\jquery-1.9.1.js">
</script>
</head>
<body>
<div id="log"></div>
<span></span>
<h1></h1>
<script>
var me = {
_panelRotationTimeout: null,
_showPanel: function(index) {
//Reset index
if (index>10000)
{
index=0;
}
$("div").text("CXY:"+index);
// set timer when to switch to next panel
var that =this;
var ind = index;
this._panelRotationTimeout = setTimeout(function () {
if (that && that._showPanel) {
that._showPanel(ind+1);
}
}, 1000);
$("h1").text("CXY=done:"+index);
}
};
me._showPanel(1);
</script>
</body>
</html>
This is clearly an issue with IE8 Garbage Collection. Intervals in Javascript are notorious for leaking memory. The fact that it runs for 3-4 days is in itself a small miracle. You should add something that will completely refresh or reload the page at least once every 24 hours, otherwise IE will sap memory until it crashes out. Firefox has better GC in its Javascript engine, which is why it's still running, but I bet given more time, that will crash too.