本文へスキップ
Kitbay
スキル

javascriptcore-garbage-collector

NOASSERTION2026年11月11日 更新96,758GitHubスター

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.

スキルの内容

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.

できること

  • 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