How ggaisenn/ggalloc works
ggalloc is a C/C++-compatible custom heap allocator with manual freeing and stack-scanning mark-and-sweep collection. Its user workflow requests a payload, reuses or grows the linked heap, then releases memory manually or through a GC cycle. The README documents first-fit allocation, splitting, coalescing, corruption checks and POSIX sbrk integration. Edges reflect explicit README statements or sampled allocator calls; the GC’s internal sweep details are partly unsampled.
Main entry points: allocator.h Metadata Blocks · allocator.cpp ggalloc · main_demo.cpp Allocator Demo
Components 16
Heap Allocation
- Allocator API
allocator.h - ggalloc
allocator.cpp - ggfree
allocator.cpp
Heap Management
- First-Fit Search
allocator.cpp - Block Splitting
allocator.cpp - Heap Growth
allocator.cpp - Metadata Blocks
allocator.h - Coalescing
allocator.cpp - Heap Bounds Check
allocator.cpp
Garbage Collection
- gggc
allocator.cpp - Mark Phase
allocator.cpp - Sweep Phase
allocator.cpp
Other components
- C/C++ Caller
- POSIX sbrk
- Thread Stack
- Allocator Demo
main_demo.cpp
Connections 22
- C/C++ Caller → Allocator API: calls
allocator.h - Allocator API → ggalloc: exposes
allocator.h - ggalloc → First-Fit Search: searches
allocator.cpp - First-Fit Search → Metadata Blocks: scans
allocator.cpp - First-Fit Search → Block Splitting: splits
allocator.cpp - ggalloc → Heap Growth: requests
allocator.cpp - Heap Growth → POSIX sbrk: grows break
allocator.cpp - Heap Growth → Metadata Blocks: links block
allocator.cpp - ggalloc → Metadata Blocks: returns payload
allocator.cpp - C/C++ Caller → ggfree: calls
- ggfree → Heap Bounds Check: validates
allocator.cpp - ggfree → Coalescing: coalesces
allocator.cpp - Coalescing → Metadata Blocks: merges neighbors
allocator.cpp - C/C++ Caller → gggc: runs cycle
- gggc → Mark Phase: runs mark
allocator.cpp - Mark Phase → Thread Stack: scans roots
allocator.cpp - Mark Phase → Heap Bounds Check: checks pointers
allocator.cpp - Mark Phase → Metadata Blocks: marks reachable
allocator.cpp - gggc → Sweep Phase: runs sweep
allocator.cpp - Sweep Phase → Metadata Blocks: reclaims blocks
allocator.cpp - Sweep Phase → Coalescing: coalesces
allocator.cpp - Allocator Demo → Allocator API: uses
main_demo.cpp