Screencast: Diagnose a JavaScript Memory Leak in the Windows IE Browser

microphone

Here’s a new screencast:

Screencast: JavaScript Memory Leaks in the Windows IE Browser

This screencast by Patrick Fitzgerald of BarelyFitz Designs discusses how he diagnosed and fixed a memory leak in a JavaScript library. It’s a very simplified example, and the same techniques probably can’t be used for more complex web applications, but it might shed some light on how these memory leaks occur.

3 Responses to “Screencast: Diagnose a JavaScript Memory Leak in the Windows IE Browser”

  1. Mark Wubben says:

    Interesting way to detect the memory usage. I’ve got one small tip though, Instead of creating a hundred tabs you could add a huge object to the tabber instance. Say, a string which is hundreds of thousands of characters long. If you make it big enough you’ll see a several megabyte increase of memory usage on every reload.

  2. pat says:

    @Mark: thanks for the tip. I did a quick experiment, and it didn’t trigger a bigger memory leak when I added data to the tabber object; however, when I attached data to the DOM element I got a bigger memory leak. This leads me to believe that the memory leak occurs in the DOM but the JavaScript object is correctly garbage-collected. I’ll have to do a little more research.

  3. pat says:

    Yep, the JavaScript garbage collector works correctly, it’s only the IE DOM garbage collector that has a bug. From Douglas Crockford’s article JScript Memory Leaks: “The JavaScript garbage collector understands about cycles and is not confused by them. Unfortunately, IE’s DOM is not managed by JScript. It has its own memory manager that does not understand about cycles and so gets very confused. As a result, when cycles occur, memory reclamation does not occur.”

Leave a Reply