Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to find memory leaks in javascript

Is there any way to find memory leaks in javascript or jquery.

i am working on javascript alot these days. I moved from middletier to UI.so I want to know if there is anyway to find them.

thanks in advance.

like image 258
kobe Avatar asked Nov 01 '10 01:11

kobe


People also ask

Are there memory leaks in JavaScript?

The JavaScript engine allocates memory when you create objects and variables in your application, and it is smart enough to clear out the memory when you no longer need the objects. Memory leaks are caused due to flaws in your logic, and they make way for poor performance in your application.


3 Answers

Memory Leak Patterns in Javascript
http://www.ibm.com/developerworks/web/library/wa-memleak/

Plugging memory leaks in JavaScript is easy enough when you know what causes them. In this article authors Kiran Sundar and Abhijeet Bhattacharya walk you through the basics of circular references in JavaScript and explain why they can cause problems in certain browsers, especially when combined with closures. After seeing some of the common memory leak patterns you should watch out for, you'll learn a variety of easy ways to work around them.

like image 102
Robert Harvey Avatar answered Oct 20 '22 17:10

Robert Harvey


Google Chrome has the ability to take heap snapshots and compare them, which can be used to detect memory leaks and analyse memory consumption in general. There is an article about heap profiling at Google Developers that explains everything.

like image 40
Torben Avatar answered Oct 20 '22 17:10

Torben


Debug.js does global leak detection and type checking.

like image 30
Evan Hahn Avatar answered Oct 20 '22 15:10

Evan Hahn