IE javascript memory usage

Posted on 2008-10-08
Last Modified: 2013-12-08
Load a page with the below code in IE7, the memory usage of the browser shoots up to about 100megs on my system and doesn't reduce down until the page is unloaded.  How do I clean up the memory the unused object is taking up?

In firefox if you try this the memory usage spikes and then a few seconds later reduces down, looks like their garbage collector takes care of it.
<script type="text/javascript">

    var obj = [];

    for (var x = 0; x < 999999; x++) obj[obj.length] = "a";

    obj = null;

    delete obj;


Open in new window

Question by:eChalk
  • 4
  • 3
LVL 44

Expert Comment

ID: 22674617
is there a purpose to this 1 million iteration loop?  Or are you just testing to see if javascript can tie up the entire system resources via the browser -- the answer is YES IT CAN !!

Author Comment

ID: 22674978
I have an extremely large page with lots of javascript objects and 3rd party components, and every time i refresh it is not releasing all of it's memory and growing very large in memory usage until the browser is closed.  This is a first step for me to be able to clean up... I'm wondering if in this case there is any way to clear the object from the browser memory without unloading the page.
LVL 18

Accepted Solution

Hube02 earned 500 total points
ID: 22675017
IE is known to have memory leaks, however, other browsers will also leak memory to some extent. There are many things that can cause this memory leakage and perhaps the code on your page incorporates some of the know issues.

You could start here:

Although, if you are using 3rd party components the problems may be difficult to locate. Many developers do not keep the problems in mind and in some cases do not know they are creating a problem. And then again, in some cases, it is not possible to avoid the problem completely.
LVL 44

Expert Comment

ID: 22675051
"I have an extremely large page with lots of javascript objects and 3rd party components"

OK, the way to debug this is to run firefox, and use tools, error console, and look for any errors.  There are also more elaborate tools like firebug -- -- which will tell you where the problems are.  

It would be a first guess to check the 3rd party components, that is what most would say.  But in your case if you are using javascript objects, I think that is the most likely place to look -- these objects will not be being closed correctly, and accumulate in the hundreds or thousands.  Try the debugging tools in firefox.
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline


Author Comment

ID: 22678453
Firefox does not have as bad a leak as IE.  What tools are available in firefox to spot leaks?  I know of this one for IE (best of the ones i looked at):
LVL 44

Expert Comment

ID: 22680912
In FF, there is the built-in error console -- for more elaborate checking of objects not being closed, try their Firebug Plug in --
LVL 44

Expert Comment

ID: 22852162
how come the comment 22680912 was not accepted then?

Author Comment

ID: 22852217
Because Firebug doesn't have an in depth memory tracing module.  Once the page unloads, theres no window to go to to see all the stuff still hanging, like the JavaScript Memory Leak Detector for IE.

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now