Optimizing Memory Performance
Separate allocation rate, allocation bytes, retained heap/RSS, locality, and peak memory. An optimization that removes allocations but retains an oversized arena or buffer can lose.
- Read memory audit and, for parsers, parser data-oriented design.
- Scan for unbounded capacity growth, copied text, per-item allocation, retained source buffers, pointer-rich structures, object-per-token records, and pools without ownership.
- Establish capacity bounds and reset/eviction rules before adding reuse, arenas, pools, or interning.
- Benchmark allocation count/bytes, peak RSS/heap, GC/allocator time, locality-sensitive throughput, and tiny-input startup separately.