182 Memory, Allocations, and GC
182 Memory, Allocations, and GC
Memory behavior is latency behavior. Allocation patterns influence GC pressure, which affects tail latency.
Runtime Path
allocate -> reachable? -> promoted/survive -> GC scan -> reclaim when unreachable
Practical Levers
- Reduce transient allocations in hot paths.
- Keep object lifetimes short when possible.
- Use pooling selectively where profiling justifies complexity.
Engineering Tradeoff
Lower allocation rates can reduce GC overhead, but aggressive pooling can increase complexity and bug risk. Favor clarity unless profiles show strong need.