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 3229846
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:51:29+00:00 2026-05-17T16:51:29+00:00

Greetings, I’ve been working on a web-interface for some hardware that uses an 8-bit

  • 0

Greetings,
I’ve been working on a web-interface for some hardware that uses an 8-bit microcontroller. The web page uses HTML, javascript, JSON and XHR (XMLHttpRequest) for its communications. What I’m trying to do is create a page that updates every 250mS with new values from the controller using setInterval so that the web page gets updated ‘real-time’ to make it feel more like an application to the user.

I’ve gotten it to work for the most part, but found that there’s a memory leak somewhere in the code with both browsers that I’ve tested, IE and Chrome.

I’ve researched this online and it seems like other people have had the same problem and I’ve tried to implement different fixes with no success.

Here are a few snap-shots of code that will hopefully explain things a little better, I’ve modified variables so they make more sense without seeing the full application.

// start the pageRefreshTimer to update values
var pageRefreshTimer = window.setInterval(updateValues, 250);

// Standard XHR opener
HTTP.getText = function(url, callback) {
    var request = HTTP.newRequest(); // Searches array of standard XMLHttpRequest functions to try, code not shown...
    request.onreadystatechange = function () {
        if (request.readyState == 4 && request.status == 200) {
            callback(request.responseText) // responseText becomes JSONText below
        }
    }
    request.open("GET", url);
    request.send(null);
}

// Function that is constantly refreshed by HTML page to simulate real-time application
updateValues = function(parameter, value) {

    newURL = newURL + "?" + parameter; // newURL is defined elsewhere in the code...

    // Send the url and create the JSONObject
    HTTP.getText(newURL, function(JSONText) {
                    var JSONObject = eval('(' + JSONText + ')'); // Specific notation for JSON

                    // Load object values into Javascript variables
                    Controller.detectorPosition = JSONObject.detectorPosition;
                    Controller.offset = JSONObject.offset;
                    Controller.actuatorPosition = JSONObject.actuatorPosition;
    });

    delete JSONObject; // My attempt at manual garbage collection, didn't resolve the memory leak
}

For your reference, the JSON file that would be sent from the microcontroller to the browser would look something like this…

{ "offset": "1500", 
"detectorPosition": "1558", 
"actuatorPosition": "120" }

Does this look like an issue with “closures” in the code?

Using the Developer Tools in Chrome (Ctrl-Shift-J), I noticed that there are multiple calls to the ParameterValues.json file (350B size) like it should since this is the JSON object that stores the values from the microcontroller; but is the browser somehow storing/caching every page in memory?

Attached in my comments are two screen shots of the issue. The second one is where I setup a break-point in the XMLHttpRequest loop, and it looks like there’s a circular reference in the “closure” panel on the right hand side. Anyone see an issue with this?

What can I do to dig deeper and get more information?

Thanks in advance!

  • 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-17T16:51:30+00:00Added an answer on May 17, 2026 at 4:51 pm

    There is a Google Code project that has created a cross-browser implementation of XMLHttpRequest. They also maintain a small list of native XMLHttpRequest bugs that might be useful to you.

    The following bug seems potentially applicable to your situation:

    Bug: The instance of XMLHttpRequest doesn’t get garbage collected in case
    you have a reference to the instance
    or to an other [sic] COM object (for
    example: DOM Node etc.) in its
    onreadystatechange handler, thus
    producing runtime memory leaks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.