Memory leak (Definition)

The consumption of memory that is not recoverable.

When the reference count for an object is zero, the object can be garbage collected. Also, because there are no references to it, you have no handle by which you can reach it, so if it isn't garbage collected, it will waste the space it occupies. When that happens, you have a memory leak.

Memory leaks typically happen in web based JavaScript when you create and destroy a lot of strings in a loop. Concatenating many strings together and extending one string incrementally is a typical leak producing technique.

Garbage collection generally only happens in web browsers when the page is refreshed.

See also:delete, Garbage collection, Memory management, Object(), Option(), Reference counting, Variable, Window.setInterval(), Window.setTimeout()

Cross-references:

Wrox Instant JavaScript - page - 29