Javascript app - memory leak

I have developed a client application and unfortunately I suspect a memory leak.
There are a lot of private clone objects in the application and at the end of each function I remove the objects by setting them to null. ( foo = null;


My question is, how should I manage the objects?
Is it enough to use foo = null


Also, are there any tools that can help me identify the problem?


Finally my problem is caused by incorrect use of jquery progress bar

        function updateProgressBar() {
        if (!handle) //by adding this, the problem solved. 
            value: ++pct
        if (pct >= 100) {
            pct = 0;
            setInterval("updateProgressBar()", 300);



source to share

2 answers

The main reason for memory leaks in the browser is when you have circular references between DOM and JavaScript objects. Mostly happens when orphaned DOM nodes are still related to event handlers or other JS objects.

Chrome Developer Tools allows you to view a bunch and analyze items that are still in memory, but not through the "Heap Profiler" used by

But to answer the actual answer, setting the property to null is enough to break circular references and fix memory leaks.



Maybe a closing problem? You should try the methods that current browsers provide, like Speed ​​Tracer for Chrome.

Anyway, the piece of code you are using would be helpful to try and identify the problem.



All Articles