Przejdź do treści
Biblioteka skilli
Programowanie · Nauka i wyjaśnianie

memory-management-guide

/memory-management-guide

Doradza, jak alokować, posiadać i zwalniać pamięć w kodzie z ręcznym zarządzaniem: bufory od wołającego, areny, pule obiektów, ownership i błędy use-after-free.

Repozytorium
platform ↗
Licencja
MIT
Ostatnia zmiana repozytorium
08.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
9
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 08.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Doradza, jak alokować, posiadać i zwalniać pamięć w kodzie z ręcznym zarządzaniem: bufory od wołającego, areny, pule obiektów, ownership i błędy use-after-free.

Wyzwalacze z opisu

t sayor
Oryginalny opis (EN)

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'.

Jak działa

  1. Essentials
  2. Allocation strategy
  3. Ownership
  4. Gotchas
  5. Progressive Disclosure
Sekcje z nagłówków SKILL.md, w oryginale · 37 linii, 317 słów
Podgląd SKILL.md
---
name: memory-management-guide
description: "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'."
---

# 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 ring buffers, end-of-page bounds checks, see [references/virtual-memory.md](references/virtual-memory.md)

## Ownership

- **Lifetime by scope** - Tie allocation lifetime to a clear scope/phase, see [references/ownership-and-lifetimes.md](references/ownership-and-lifetimes.md)
- **Handles over pointers** - Reference relocatable storage by index/handle (layout detail in data-oriented-design-guide), see [references/ownership-and-lifetimes.md](references/ownership-and-lifetimes.md)

## Gotchas

- Bump allocation has no bounds safety unless you check capacity; always assert/return on overflow.
- Two owners means double-free or leak; decide ownership explicitly, don't infer it.
- Pointers into a growing/reset allocation dangle. Prefer offsets/handles across a boundary (a virtual-memory reserve/commit block is the exception: it never moves).

## Progressive Disclosure

- Read [references/caller-owns-memory.md](references/caller-owns-memory.md) - Load when designing an API's allocation boundary or a non-allocating library
- Read [references/arenas-and-pools.md](references/arenas-and-pools.md) - Load when choosing an allocator: arena, pool, scratch, or virtual-memory backed
- Read [references/virtual-memory.md](references/virtual-memory.md) - Load when using address-space reservation for cap-free arrays, ring buffers, page-aligned growth, or end-of-page bounds checking
- Read [references/ownership-and-lifetimes.md](references/ownership-and-lifetimes.md) - Load when deciding who owns/frees memory and how long it lives
Pliki w paczce (9)
  • SKILL.md 3 KB
  • SOURCES.md 3 KB
  • eval-queries.json 4 KB
  • evals.json 3 KB
  • moon.yml 1 KB
  • references/arenas-and-pools.md 3 KB
  • references/caller-owns-memory.md 2 KB
  • references/ownership-and-lifetimes.md 2 KB
  • references/virtual-memory.md 4 KB

Wersje

W bazie nie ma innych skilli o nazwie memory-management-guide.

Migawka bazy z 13.11.2026 · wersja paczki ff766b41f665 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100memory-allocators-arenas-c
    Projektuje, implementuje i weryfikuje własne alokatory pamięci w C i C++: Arena i Bump, pule bloków stałego rozmiaru oraz Free-List, z dbałością o wyrównanie i lokalność cache, np. dla silników gier i HFT.
  • 100memory-management
    Projektuje pamięć silnika gry: hierarchię alokatorów ramkowych, arenowych i pulowych, układ przyjazny pamięci podręcznej oraz budżety i pamięć GPU.
  • 90cc-native-memory-safety
    Diagnozuje i naprawia wycieki pamięci, użycie po zwolnieniu, podwójne zwolnienie i błędy zakresów w kodzie C i C++.
  • 100c-modern-c23-memory-management
    Pomaga pisać wydajny kod systemowy w C23, z ręcznym zarządzaniem pamięcią i zapobieganiem przepełnieniom buforów.
  • 95rust-ownership-system
    Opisuje system własności w Rust: reguły własności, pożyczanie, lifetimes i bezpieczeństwo pamięci.
  • 100custom-allocators
    Opisuje własne alokatory pamięci: pool, slab i arena, strojenie jemalloc i mimalloc, GlobalAlloc w Rust oraz benchmarki alokatorów i fragmentację.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.