Microsoft releases Free JavaScript Leak Detector
Paoli Severini from Microsoft's Global Product Development Team has released a tool called JSLeaks Detector which facilitates finding memory leaks in Internet Explorer. Several articles have been published on how circular references occur in Internet Explorer and how to avoid them. However, this requires the developer to be constantly on guard and even the most seasoned developers slip up at times. This will allow a simple way to test your pages for memory leaks and be aware of when you are leaking memory.
JSLeaks Detector screenshot
A basic memory leak (in IE 6) as shown on the release page:
<html>
<head>
<script language="JScript">
var jsObject;
function SetupLeak()
{
jsObject = document.getElementById("LeakedDiv");
document.getElementById("LeakedDiv").expandoProperty = jsObject;
}
</script>
</head>
<body onload="SetupLeak()">
<div id="LeakedDiv"></div>
</body>
</html>
Here the SetupLeak() function creates a circular reference which will leak in IE 6.
The tool installs as a plugin to Internet Explorer 6 and 7 under both Windows XP and Vista. It will be interesting to see if any of the techniques used by Microsoft will be picked up by other IE memory leak tools like sIEve and Drip.
- Login or register to post comments
- 4685 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)










Comments
awealthyaffiliate replied on Fri, 2009/02/20 - 3:15pm
Note, this does work pretty well. In using this, I was able to verify some leaks. Please note, when testing with this make sure to do a base check against other sites. For example, we tracked changes on our site and thought we had a ton of memory leaks. After comparing our statistcs to other sites, we actually had a minimal amount and the memory increases were browser related and not code related.
Another tip, we also found memory leaks by working with our site, then going to a separate site and coming back. This showed broken references as well.
Programmers! Make extra money on the side.