Click here to Skip to main content
13,054,329 members (120,656 online)
Rate this:
Please Sign up or sign in to vote.
I found a memory leak in the following code (the else block)
if (browser == "Microsoft Internet Explorer"){
    if (vers < 7){
        document.getElementById("theData").src = "data.js";
            xmlHTTP = new XMLHttpRequest();
  'GET', "data.js", false);
            xmlHTTP = null;
            delete xmlHTTP;
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'data.js';
}//end if

Your help is appreciated!
Posted 26-Mar-13 11:08am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I don't think you can do anything about it.

Are you sure you really detected the leak? How? Not all methods are reliable. Anyway, if you do have a leak, you cannot prevent it. All complains go to Microsoft :-(

Sameer Alomari 26-Mar-13 17:52pm
if I comment xmlHTTP.send(null); then the memory is stable! any clue?
Sergey Alexandrovich Kryukov 26-Mar-13 19:06pm
I don't know. Garbage in — garbage out. Why would anyone send null in HTTP request?
Anyway, the host system, in this case, IE7 should not allow leaks, no matter what happens in JavaScript code. So, my question is: what kind of leak and how you detect it?
Does the memory use grow in unlimited manner if you repeatedly do the HTTP request? Does to grow is you reload the same page several time and do HTTP request? And how do you measure it?
Sameer Alomari 27-Mar-13 16:17pm
This code is called by a timer every second to pull data.js file from the server, So I get a leak because the application calls this code constantly
Sergey Alexandrovich Kryukov 27-Mar-13 16:38pm
Well, I do understand what happens when you have a leak, I'm still not sure you have it... Anyway, use the memory debugger.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 26 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100