← ClaudeAtlas

memory-management-guidelisted

Use when deciding how memory is allocated, owned, and freed in manual-memory or buffer-passing code, in any language. Triggers on prompts about caller-owns-memory / caller-provided buffers, arena/bump/linear allocators, object pools and free lists, virtual-memory reserve/commit, scratch/temp allocators, object lifetimes, ownership (single-owner/borrow), leaks/use-after-free/double-free, even when the user doesn't say 'memory' or 'allocator'.
xonovex/platform · ★ 5 · Code & Development · score 72
Install: claude install-skill xonovex/platform
# Memory Management Guidelines General principles for allocating, owning, and freeing memory in manual-memory or buffer-passing code. Language-agnostic; examples are in C. Domain skills (e.g. C99, GPU device memory) keep their own specifics and link here for the underlying principle. ## Essentials - **Caller owns memory** - APIs take caller-provided storage; never allocate internally, see [references/caller-owns-memory.md](references/caller-owns-memory.md) - **Group by lifetime** - Allocate together what dies together; free as a unit, see [references/ownership-and-lifetimes.md](references/ownership-and-lifetimes.md) - **One owner** - Exactly one owner frees; everyone else borrows, see [references/ownership-and-lifetimes.md](references/ownership-and-lifetimes.md) ## Allocation strategy - **Arena / bump** - Pointer-bump from a block; reset frees everything at once, see [references/arenas-and-pools.md](references/arenas-and-pools.md) - **Object pool** - Fixed-size slots + free list; O(1) alloc/free, stable, see [references/arenas-and-pools.md](references/arenas-and-pools.md) - **Scratch / temp** - Per-frame/per-request arena reset each cycle, see [references/arenas-and-pools.md](references/arenas-and-pools.md) - **Virtual-memory reserve/commit** - Reserve a large range, commit pages on demand; stable addresses, no realloc copy, see [references/arenas-and-pools.md](references/arenas-and-pools.md) - **Virtual-memory tricks** - Cap-free arrays, page-aligned growth, gapless rin