Each ProcessingPayments() used memory increase. CollectGarbage() not helps. Use Drip to view memory usage, but don't view any DOM leaks.
I use only IE8 and tested on older versions. Other browsers not interested.
How can I decrease growing memory usage while execute this script?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JS IE XMLHTTP - Memory leaks</title>
</head>
<body onload="ProcessingPayments();locCollectGarbage();">
<script language="JScript">
var toProcessingPayments;
var ProcessingPaymentsPeriod = 1*60*1000;
var SessionCount = 1;
var CollectGarbageCount = 1;
function ProcessPayment(arrParams) {
var e;
var strURL = "http://www.facebook.com/";
var strURLParam = "";
try { var locHTTPRequest = new ActiveXObject("MSXML2.XMLHTTP.6.0"); }
catch (e) { var locHTTPRequest = new ActiveXObject("MSXML2.XMLHTTP"); }
function ProcessPaymentHTTPRequest() {
if (locHTTPRequest.readyState != 4) {
return;
}
if (locHTTPRequest.status != 200) {
document.getElementById("CurrentSession").innerHTML = document.getElementById("CurrentSession").innerHTML
+arrParams.i+" = error code "+locHTTPRequest.status+"<br />";
return false;
}
if (locHTTPRequest.getResponseHeader("Content-Type").indexOf("text/html") < 0) {
document.getElementById("CurrentSession").innerHTML = document.getElementById("CurrentSession").innerHTML
+arrParams.i+" = wrong content type "+locHTTPRequest.getResponseHeader("Content-Type").indexOf("text/html")+"<br />";
return false;
}
try {
document.getElementById("CurrentSession").innerHTML = document.getElementById("CurrentSession").innerHTML
+arrParams.i+" = processed<br />";
return true;
}
catch(e) {
if (locHTTPRequest.responseXML.parseError != 0) {
return false;
}
else {
return false;
}
}
locHTTPRequest.abort();
delete locHTTPRequest["onreadystatechange"];
locHTTPRequest = null;
} // function ProcessPaymentHTTPRequest()
strURLParam = "?"+arrParams.i;
locHTTPRequest.open("get", strURL+strURLParam);
document.getElementById("CurrentSession").innerHTML = document.getElementById("CurrentSession").innerHTML
+arrParams.i+" = request<br />";
locHTTPRequest.onreadystatechange = ProcessPaymentHTTPRequest;
locHTTPRequest.send(null);
}
function ProcessingPayments(arrPayment) {
var e;
toProcessingPayments = null;
document.getElementById("CurrentSession").innerHTML = "";
for (var i = 0; i < 10; i++) {
ProcessPayment({
i: i
});
}
SessionCount++;
document.getElementById("Session").innerText = SessionCount;
toProcessingPayments = setTimeout(ProcessingPayments, ProcessingPaymentsPeriod);
}
function locCollectGarbage() {
CollectGarbage();
document.getElementById("CollectGarbage").innerText = CollectGarbageCount;
CollectGarbageCount++;
setTimeout(locCollectGarbage, 5*60*1000);
}
</script>
</body>
<p>Sessions: <span id="Session">0</span></p>
<p>CollectGarbage(): <span id="CollectGarbage">0</span></p>
<hr />
<br />
<p>Current session:</p>
<p id="CurrentSession"></p>
</html>