How sdogruyol/gcry works
gcry is a Crystal-native, shard-delivered conservative mark–sweep garbage collector that replaces Boehm when an application is built with -Dgc_none. The documented runtime workflow routes Crystal allocation through gcry’s GC interface, tracks heap objects and roots, marks reachable objects during stop-the-world collection, then sweeps and releases unused memory. The README also documents platform support, optional precise-layout research mode, and built-in metrics. The supplied source excerpts mainly identify override, raw-output, scan, and stop-the-world modules; internal call wiring beyond the documented workflow is therefore kept intentionally broad.
Main entry points: stw_slots.cr Stop World · gc_override.cr GC Override · gcry Root Scanning · collect_scan.cr Collection Scan
Components 15
GC Runtime
- GC Override
src/gcry/gc_override.cr - Heap Allocator
src/gcry - Object Layout
src/gcry
Collection
- Root Scanning
src/gcry - Stop World
src/gcry/stw_slots.cr - Mark Phase
src/gcry - Sweep Phase
src/gcry - Collection Scan
src/gcry/collect_scan.cr - Precise Stack Maps
src/gcry
Platform Support
- Linux Support
src/gcry/platform/linux_stw.cr - Darwin Support
src/gcry/platform/darwin_stw.cr - Windows Support
src/gcry/platform/windows_stw.cr
Metrics
- GC Metrics
src/gcry - Prometheus Export
src/gcry
Other components
- Crystal Application
Connections 15
- Crystal Application → GC Override: allocates through
- GC Override → Heap Allocator: routes allocation
- Heap Allocator → Object Layout: uses layout
- GC Override → Stop World: triggers collection
- Stop World → Root Scanning: coordinates scanning
- Root Scanning → Collection Scan: scans roots
- Collection Scan → Mark Phase: marks reachable
- Mark Phase → Sweep Phase: hands off marks
- Sweep Phase → Heap Allocator: reclaims blocks
- Stop World → Linux Support: platform control
- Stop World → Darwin Support: platform control
- Stop World → Windows Support: platform control
- GC Override → GC Metrics: records activity
- GC Metrics → Prometheus Export: exports metrics
- Root Scanning → Precise Stack Maps: optional precision