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?

Decision

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

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

      

+3


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. http://code.google.com/chrome/devtools/docs/heap-profiling-dom-leaks.html

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 http://gent.ilcore.com/2011/08/finding-memory-leaks.html



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

+3


source


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.

0


source







All Articles