Google Open Sources Leak Finder, a JavaScript Tool for Detecting Memory Leaks

by Abel Avram on Aug 09, 2012 |

Google has open sourced Leak Finder, a tool inspecting the heap of JavaScript applications in order to find memory leaks.

As a garbage collected language JavaScript does not have the usual memory leaks typically found in other languages such as C++. But when memory is still allocated to objects that are no longer used it is said that the application has memory leaks, and if the leaks are important then the application may show reduced performance or even fail to execute.

One of the ways of possibly getting a memory leak in JavaScript is with circular references, especially when closures are used. Leak Finder can detect when a closure produces a leak, warning the developer and pointing to the faulty code. The tool looks for Google Closures’ goog.Disposable objects in the heap, verifying if the dispose() method was called and whether event listeners were released, because they can hold references to DOM objects, thus leaking memory.

Currently, Leak Finder works with Closures but it can be configured to work with other libraries. Closures is an open source JavaScript library containing widgets, an event framework, tools for DOM manipulation, a unit testing framework, animation tools, and other components, being used extensively across Google services such as GMail, GDocs, GMaps and others.

Also, code analysis must be done with Chrome 21 or later using remote debugging and the development tools.

Google open sourced in the past a number of other JavaScript tools such as the Closure Compiler, a tool generating compact and high performance code, Closure Templates for dynamically generating HTML, Closure Linter, a JavaScript style checker, and Closure Stylesheets, a set of extensions to CSS. GWT, another toolkit for building JavaScript applications, has had a release candidate in June, but its future is uncertain since Google has moved many of their GWT developers to Dart, which is seen as “an ambitious evolution of GWT’s mission to make web apps better for end users, and we’re optimistic about its potential.”

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

garbage collecting and circular references by o f

I am not an expert but a garbage collecting language isn't vulnerable to circular reference related memory leaks is it? Rather reference counting languages are.
I don't know what Javascript is but I would guess reference counting.

Please someone correct me if I am wrong.

Re: garbage collecting and circular references by Abel Avram

Check out this rather old but still actual post:

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

2 Discuss

Educational Content

General Feedback
Editorial and all content copyright © 2006-2014 C4Media Inc. hosted at Contegix, the best ISP we've ever worked with.
Privacy policy