What's wrong with my Javascript? Memory Leak/Circular Reference

K

kstahl

I'm trying to use the XmlHttpRequest object from a windows CE device
under IE. When I do I get some serious memory leaks. It doesn't seem
to happen running the same code on Desktop IE. Any of you Javascript
experts care to offer an opinion?

This seems to have been an issue a few years ago on Desktop browswers
but it has either been fixed or a workaround was dicovered. Do the
AJAX libraries have a solution?

I've created a simple test to isolate the problem. I have two simple
html
files on the CE Device (the web server)

Xml.htm contains the following:
<html>
<head>
</head>
<body onload="updateXml(0);">
<form name="form1">
Counter and Response:
<textarea name="xmlResponse" cols=80
rows=10></textarea>
xmlHttpRequest Ready State:
<input name="readystate">
Update Interval (milliseconds):
<input name="interval" value="1000">
</form>
<script language="JavaScript">
var xmlObj=null;
var count = 0;

function updateXml(input)
{
var url;
url = "RealtimeXml.htm?Param=" + input;

xmlObj = new
ActiveXObject("Microsoft.XMLHTTP");
xmlObj.onreadystatechange =
processReqChange;
xmlObj.open("GET", url, true);
xmlObj.send(null);
}
function processReqChange()
{
document.form1.readystate.value =
xmlObj.readyState;
if(xmlObj.readyState == 4)
{

document.form1.xmlResponse.value = count + "\n" +
xmlObj.responseText;
count++;
setTimeout("updateXml(" + count
+ ")",
document.form1.interval.value);
}
}
</script>
</body>
</html>

The second file is called RealtimeXml.htm and contains a single
character '1'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top