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

Discussion in 'Javascript' started by kstahl@doboy.com, Dec 17, 2005.

  1. Guest

    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'.
    , Dec 17, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kiuhnm
    Replies:
    16
    Views:
    728
    Jonathan Mcdougall
    Jan 3, 2005
  2. Stewart
    Replies:
    0
    Views:
    1,386
    Stewart
    Jul 27, 2006
  3. s.subbarayan

    Dynamic memory allocation and memory leak...

    s.subbarayan, Mar 18, 2005, in forum: C Programming
    Replies:
    10
    Views:
    681
    Eric Sosman
    Mar 22, 2005
  4. cham
    Replies:
    5
    Views:
    756
  5. Mark Probert
    Replies:
    4
    Views:
    317
    Mark Probert
    Feb 9, 2005
Loading...

Share This Page