# Memory allocation patterns, leaks, heap pressure, fragmentation. ## Measure - heap profiling → allocation rate, live heap, pause/freq of reclamation - allocation tracking → hot allocators, sites - reclamation logs → frequency, duration, cause - metrics → bytes/sec, heap trend, reclamation overhead % ## Optimize - reuse objects/buffers for short-lived values - avoid allocations in hot loops (pre-allocate, reuse buffers) - efficient data structures (contiguous over pointer-chasing for sequential access) - tune allocator/reclamation params if applicable - size objects to fit cache lines; avoid fragmentation - avoid boxing/copying where the runtime does it implicitly ## Pitfalls - premature opt: small alloc reductions may not matter if allocator is fast - over-reusing: complexity + hidden leaks - ignoring reclamation: reducing allocs may not help if reclamation already efficient - peak heap ≠ average; average matters for throughput