What is JavaScript garbage collection?
Eric Lippert wrote a blog post about this subject a while back (additionally comparing it to VBScript). More accurately, he wrote about JScript, which is Microsoft’s own implementation of ECMAScript, although very similar to JavaScript. I would imagine that you can assume the vast majority of behaviour would be the same for the JavaScript engine of Internet Explorer. Of course, the implementation will vary from browser to browser, though I suspect you could take a number of the common principles and apply them to other browsers. Quoted from that page: JScript uses a nongenerational mark-and-sweep garbage collector. It works like this: • Every variable which is “in scope” is called a “scavenger”. A scavenger may refer to a number, an object, a string, whatever. We maintain a list of scavengers — variables are moved on to the scav list when they come into scope and off the scav list when they go out of scope. • Every now and then the garbage collector runs. First it puts a “mark” on eve