DEV Community


Discussion on: How Memory Is Allocated In JavaScript.

kelvinkirima014 profile image
Kelvin Kirima Author

All modern browsers have a mark and sweep garbage collector. Javascript has come up with ways to improve garbage collection such as:

  1. parallel collection - where the main javascript thread has multiple helper threads help in garbage collection.
  2. incremental collection - all collection is carried by the main thread but in intermittent stages.
  3. concurrent collection - main thread runs javascript code uninterrupted and all garbage collection is done by helper threads. (I should add an article on this) and this means that circular references are no longer a problem. Yes, we don't have control over garbage collection as there is no form of manual garbage collection (I think this is something javascript should change). Thanks for your comment mate!
Forem Open with the Forem app