Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What is JavaScript garbage collection?

collection garbage Javascript
0
Posted

What is JavaScript garbage collection?

0

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

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123