Forcing Garbage Collection

1 min read
Rapid overview

Forcing Garbage Collection (JavaScript)

In production JavaScript, you generally do not force GC. Let the engine manage it.


Notes

  • Forcing GC can cause UI jank and unpredictable pauses.
  • In browsers, manual GC is not exposed.
  • In Node.js, --expose-gc exists for testing, not production.

Interview prompt

  • Why is forcing GC a bad idea in UI apps?