Zum Inhalt springen
Kitbay
Skill

javascriptcore-garbage-collector

NOASSERTIONAktualisiert am 11. Nov. 202696.758GitHub-Sterne

A contributor reference in the Bun repository on how JavaScriptCore's garbage collector works inside Bun, for debugging use-after-free bugs, leaks and objects freed too early, or for writing native code that touches the collector.

Was der Skill vermittelt

A contributor reference in the Bun repository on how JavaScriptCore's garbage collector works inside Bun, for debugging use-after-free bugs, leaks and objects freed too early, or for writing native code that touches the collector. It covers how roots are found, including conservative stack scanning and its limits, the cell header and write barriers, allocation in isolated subspaces, the rules for tracing hooks that run concurrently, opaque roots, weak references and finalisers, Bun's pattern of holding a strong reference only while work is active, reporting extra native memory, and heap snapshots. A table helps pick the right way to keep an object alive, and environment variables for stress-testing the collector are listed.

Funktionen

  • Diagnose use-after-free and premature collection bugs
  • Choose a keep-alive mechanism for native objects
  • Write tracing hooks and write barriers safely
  • Stress the collector with debug environment variables