Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6338027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:21:50+00:00 2026-05-24T19:21:50+00:00

I have a JavaScript application that uses XMLHttpRequest to fetch and parse about 60,000

  • 0

I have a JavaScript application that uses XMLHttpRequest to fetch and parse about 60,000 XML documents. However, IE’s memory usage grows quickly, and eventually the program crashes. I suspect this has to do with IE’s JScript GC. Below is a simplified version of my code:

Above the code, I declare two variables:

var xmlhttp;
var xmlDoc;

When the code first starts running, I set the value of xmlhttp:

xmlhttp = new XMLHttpRequest();

The script then enters the main loop:

function loadXML() {

    xmlhttp.abort(); 
    xmlhttp.open("GET", url, false);
    xmlhttp.setRequestHeader('Content-Type', 'text/xml', 'Pragma', 'no-cache');
    xmlhttp.send("");
    while (xmlhttp.readyState != 4) { }
    xmlDoc = xmlhttp.responseXML;
    setTimeout("readXML()",0);

}


function readXML() {

    //Reads the XML.
    //If all data has been retrieved, exit loop.
    //Else, change the url and go back to loadXML()

}

Google Chrome runs the code just fine, with no errors. However, IE loops about 2000 times before crashing with an “Out of Memory” error. Is the Garbage Collector not doing it;s job? Can I rewrite my code to prevent problems?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:21:52+00:00Added an answer on May 24, 2026 at 7:21 pm

    You should not use a busy loop at all to wait for the result of an XMLHttpRequest. Also, there’s no reason to have the xmlhttp object public. Instead, create a new one on every call and register a callback:

    function loadXML() {
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.open("GET", url, false);
        xmlhttp.setRequestHeader('Content-Type', 'text/xml', 'Pragma', 'no-cache');
        xmlhttp.onreadystatechange = function() {
          if (xmlhttp.readyState == 4) {
            xmlDoc = xmlhttp.responseXML;
            readXML();
          }
       };
       xmlhttp.send("");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that uses TONS of javascript, and as usual, there
I am currently working on rails3 application that uses jQuery. I have a javascript
I have developed a web application for mobile phones that uses JavaScript Google API.
I have a mobile web application that uses the Javascript SDK to connect to
I have made an iframe style facebook application that uses php and javascript (jquery).
I have a PHP application that makes extensive use of Javascript on the client
I have a flex application that needs the ability to generate and execute JavaScript.
I want to run javascript/Python/Ruby inside my application. I have an application that creates
I have some pages that reference javascript files. The application exists locally in a
I have about 2000 lines of javascript code for my application. A lot of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.