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.
Prev | Home | Next |
Memory allocation | Up | Memory management |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |