custom memory vector · one engine, three views

Memory simulator

A single real allocator (first-fit free list + bump pointer, matching heap_manager.cpp exactly) driving three views below: a guided replay of the push_back.svg growth scenario, a free-form sandbox, and a byte-level header inspector. Nothing here is scripted text — every number comes from actually running the algorithm.

1. Guided walkthrough — push_back on a full vector

Sets up an int vector at capacity 2 and fills it, then runs one real push_back(vec, 30) call. Each card below is generated from that call's actual log output, not pre-written.

scenario: vec_int_init(2); push_back(10); push_back(20); — now full

addr 0heap_top = 0

2. Sandbox

Create as many int/double vectors as you like, push them past capacity, free them, and watch both free lists (kept separate, matching the actual source) recycle blocks.

create a vector

active vectors

none yet — create one above

heap layout click a block to inspect it below

addr 0heap_top = 0
int (allocated) double (allocated) free (reusable) unallocated arena

free lists

execution log

3. Header anatomy

Select a block in the sandbox heap above, then click a field to see its exact byte range within that block.

16-byte block header

+0sizeactive elements
+4capacityallocated slots
+8is_free0 alloc / 1 free
+12next_freefree-list link, -1 = NULL

selected block

click a block in the sandbox heap above