Interesting observation with IE and javascript memory management

On Windows, when the application is minimized, the OS frees up memory associated with the application by placing data in a page file. Other garbage collection may also be performed.

In the case of an Internet browser running my javascript application, I find that if memory usage starts at 60 MB, then minimizing the browser reduces the memory to 17 MB. Maximization then restores up to 40 MB.

An increase of 20 mb.

My application makes heavy use of javascript, and I suspect that IE forces a large collection of objects that are no longer referenced.

Through javascript (IE only) you can force garbage collection through:

CollectGarbage() 

So, if I call this method (without minimizing the screen), I return only mega or 2.

If I call this through the event queue:

 setTimeout(CollectGarbage, 1000) 

I am returning about 3 megabytes

My application is designed for the whole day, so memory management is very important.

Anyone have any ideas how to get IE to clear their memory to the same extent as a manual mini-pen?

Suggestions for software reduction of the browser will mock us!

Greetings :)

+4
source share
1 answer

Use the delete keyword to determine the value of the / property variable while preserving memory. More details here .

But if you only need to lose the reference to the property of the object, just set it to null and wait for the next collection.

Be careful about using closures and lambda functions, as they are traditionally memory pigs and sources of leaks. See Understanding and resolving Internet Explorer leak patterns .

+1
source

All Articles