Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need someone smarter than me to look at this

Status
Not open for further replies.

hatrabbit

Technical User
Jan 12, 2005
1
US
Hello,
I have serve a page of data on my intranet that's updated frequently using ajax. Everything is great except that my memory usage climbs higher and higher until the page freezes (in IE 6, 7, and 8 but not in Firefox). I ran it in several leak detection utilities and they all indicated no memory leaks. By disabling elements of the Javascript and removing functions, I have isolated the problem to this piece of script:
--------------------------------------------------------
function ajaxTrigger(url) {
if (document.getElementById) {
var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(url);
}
if (x) { // got something back
x.onreadystatechange = function() {


//main fuction goes here


}
x.open("GET", url, true);
x.send(null);


if ( (maxupdates == 0) || (updates < maxupdates-1)) {
setTimeout("ajaxTrigger(flashFile + '?' + new Date().getTime())", reloadTime);

}
}

}

--------------------------------------------------

Is there anything in the above script that jumps out as something that would prevent memory from being released? Let me know if any other information is needed, any and all responses will be greatly appreciated.
 
I'd take a look at the reloadTime parameter and how the maxupdate variables is actualized.

Cheers,
Dian
 
Instead of depending on x going out of scope, try explicitly releasing it:

...
x.send(null);
x = null;
...

If nothing else it will at least get collected sooner (maybe). As it is now, it doesn't go out of scope until the timeout expires.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top