Memory fragmentation divides free heap memory into separated regions, making allocation requests harder to satisfy and potentially causing allocation failure. section 7.2.5 section 7.0
In embedded firmware, fragmentation depends partly on how and how often the program allocates:
- It is rare with infrequent or predictable allocations, but becomes a concern with unpredictable bursts over long uptimes. section 7.2.5
- Repeated Vec growth can trigger reallocations that copy elements and free earlier blocks; Vec::with_capacity reserves space up front and reduces fragmentation. section 7.2.6
- Use embedded-alloc with llff by default; consider tlsf or buddy_system_allocator only if profiling shows allocator behavior is a problem. section 7.2.5
Reserve for expected growth
For a Vec expected to hold 100 readings, Vec::with_capacity(100) makes one allocation up front instead of growing through repeated pushes. section 7.2.6


