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.
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.
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.
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.
Debug.js does global leak detection and type checking.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With