Click here to Skip to main content
Rate this: bad
good
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";
            }else{
                    xmlHTTP = new XMLHttpRequest();
                    xmlHTTP.open('GET', "data.js", false);
					xmlHTTP.send(null);
					eval(xmlHTTP.responseText);
					window.execScript(xmlHTTP.responseText);
					xmlHTTP = null;
					delete xmlHTTP;
	        }
        }else{
            var script = document.createElement('script');
            script.type = 'text/javascript';
            script.src = 'data.js';
            document.getElementsByTagName('head')[0].appendChild(script);
        }//end if
        refreshCount=0;
Your help is appreciated!
Posted 26-Mar-13 12:08pm

1 solution

Rate this: bad
good
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 Frown | :-(
 
—SA
  Permalink  
Comments
Sameer Alomari at 26-Mar-13 17:52pm
   
if I comment xmlHTTP.send(null); then the memory is stable! any clue?
Sergey Alexandrovich Kryukov at 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?
—SA
Sameer Alomari at 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 at 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.
—SA

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

  Print Answers RSS
0 OriginalGriff 200
1 Kamal Rocks 184
2 PIEBALDconsult 150
3 BillWoodruff 148
4 Jochen Arndt 135
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 26 Mar 2013
Copyright © CodeProject, 1999-2014
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