[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73DREZNNPZ1R0ZFWMEXZC4B":3,"skill-same:01M73DREZNNPZ1R0ZFWMEXZC4B":51},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":32,"ownerHtmlUrl":33,"ownerBlogUrl":34,"ownerDescription":35,"updatedAt":36,"install":37,"resources":50},"01M73DREZNNPZ1R0ZFWMEXZC4B","memory-allocator-from-scratch",null,"Use when implementing a custom malloc\u002Ffree-style memory allocator from first principles — not when just using a language's built-in allocator. Triggers on: 'write a malloc implementation', 'build a memory allocator', 'free list allocator', 'buddy allocator', 'slab allocator', 'implement my own malloc\u002Ffree'. Covers free-list design, block metadata, coalescing, alignment, and allocator strategy tradeoffs.","Horonomos-laps\u002FYana-AI","Horonomos-laps","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F355299122?v=4","01M76B3QPXE88ET2SQPDPVATZT"," Horonomos-laps","01M72ZQRJPCYPSSWT4D00VJR2A",13,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fmemory-allocator-from-scratch\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: memory-allocator-from-scratch\ndescription: \"Use when implementing a custom malloc\u002Ffree-style memory allocator from first principles — not when just using a language's built-in allocator. Triggers on: 'write a malloc implementation', 'build a memory allocator', 'free list allocator', 'buddy allocator', 'slab allocator', 'implement my own malloc\u002Ffree'. Covers free-list design, block metadata, coalescing, alignment, and allocator strategy tradeoffs.\"\norigin: yana-ai — synthesized from classic allocator literature (K&R malloc, dlmalloc design notes, jemalloc\u002Ftcmalloc public design docs) and community from-scratch tutorials indexed in codecrafters-io\u002Fbuild-your-own-x\nlicense: Apache-2.0\nversion: 1.0.0\ncompatibility: yana-ai >= 0.43.2\n---\n\n# \u002Fmemory-allocator-from-scratch\n\n## When to Use\n\n- Implementing `malloc`\u002F`free`\u002F`realloc` semantics from raw memory (e.g. over `mmap`\u002F`sbrk`, or a fixed byte array) for teaching, an embedded target, or a custom-runtime project.\n- Choosing between allocator strategies (bump, free-list, buddy, slab) for a specific workload and needing the actual tradeoffs, not just the names.\n- Debugging fragmentation, use-after-free, or double-free in a hand-rolled allocator.\n\n## Do NOT use for\n\n- Application-level memory management in a language with a GC or a mature allocator (JS, Python, Go, Java) — there is nothing to build here, use the runtime's allocator.\n- General performance profiling of memory usage — see `memory-leak-detection` and `profiling-benchmarking` instead.\n- Production allocator replacement — use jemalloc\u002Fmimalloc\u002Ftcmalloc; this skill is for understanding the mechanism, not shipping a faster malloc than decades of tuned production allocators.\n\n---\n\n## Strategy Decision\n\n```\nNeed the simplest possible allocator, never freeing individual objects?\n  → Bump allocator (Step 1) — O(1) alloc, no free, reset all at once\n\nNeed general alloc\u002Ffree of variable sizes, simplicity over raw speed?\n  → Free-list allocator (Step 2) — the \"classic malloc\" approach\n\nNeed to minimize external fragmentation with fast coalescing?\n  → Buddy allocator (Step 3) — power-of-2 sizes, easy merge, some internal waste\n\nNeed fast alloc\u002Ffree of many same-sized objects (e.g. a fixed struct)?\n  → Slab allocator (Step 4) — pre-carved fixed-size slots, near-zero overhead per alloc\n```\n\n## Step 1: Bump Allocator (baseline)\n\nSimplest possible allocator: keep one pointer to the next free byte, hand out `size` bytes and advance the pointer. No `free()` — the whole arena resets or is discarded at once (common in arena\u002Fregion allocators for a single request's lifetime, e.g. a per-frame game allocator or a per-HTTP-request arena).\n\n```\nalloc(size):\n  aligned = align_up(next_free, ALIGNMENT)\n  if aligned + size > arena_end: return OUT_OF_MEMORY\n  next_free = aligned + size\n  return aligned\n```\n\n## Step 2: Free-List Allocator\n\nThe mechanism behind classic `malloc`. Every allocated AND free block gets a small header before the returned pointer:\n\n```\nstruct BlockHeader {\n  size_t size;       \u002F\u002F payload size, not including header\n  bool   is_free;\n  BlockHeader* next; \u002F\u002F intrusive linked list of free blocks\n}\n```\n\n`alloc(size)`: walk the free list looking for a block big enough.\n- **First-fit**: take the first block that fits — fast, can fragment.\n- **Best-fit**: scan for the smallest block that fits — less waste per allocation, slower, can leave many tiny unusable fragments over time.\n- If the found block is much bigger than needed, **split** it: carve off the requested size, leave the remainder as a new (smaller) free block.\n\n`free(ptr)`: walk back from `ptr` to its header, mark `is_free = true`, then **coalesce** with adjacent free blocks (check the block immediately before and after in memory address order, merge if both are free) — without coalescing, freed memory fragments into unusable slivers over time even though total free bytes is fine.\n\n**Alignment**: most platforms require allocations aligned to 8 or 16 bytes (SIMD types need more). Round the requested size up to the alignment boundary before computing block size — an unaligned pointer returned to the caller can crash on some architectures (e.g. ARM strict alignment) or silently corrupt SIMD loads.\n\n## Step 3: Buddy Allocator\n\nOnly allocates in power-of-2 sizes. The whole arena starts as one free block of size `2^max`. To satisfy a request, repeatedly split the smallest available block in half (\"buddies\") until you reach the smallest power-of-2 that fits the request. To free, check if your buddy (computable directly from your address via XOR with the block size) is also free — if so, merge back into the parent block, and recurse the check upward.\n\nTradeoff vs free-list: coalescing is O(log n) and address-computable (no list walk needed to find the buddy), but every allocation rounds up to the next power of 2 — a 65-byte request costs 128 bytes (internal fragmentation).\n\n## Step 4: Slab Allocator\n\nFor a workload that allocates\u002Ffrees many objects of the SAME fixed size (e.g. kernel `task_struct`, a game's particle objects): pre-allocate a \"slab\" (a page or arena) already carved into fixed-size slots, and track free slots with a simple bitmap or intrusive free list of slot indices. Alloc and free are both O(1) with no header-walking or fragmentation concerns, since every slot is identical size.\n\n## What NOT to Do\n\n- Don't skip the header — without per-block metadata, `free()` has no way to know a block's size or its free-list neighbors.\n- Don't forget alignment — misaligned pointers are a portability bug that won't show up on every platform\u002Fcompiler, making it easy to ship broken and not notice.\n- Don't free() without coalescing adjacent blocks — a free-list allocator that never merges will eventually report \"out of memory\" while holding plenty of free (but fragmented) bytes.\n- Don't reach for buddy or slab allocators before a free-list works correctly — they solve fragmentation\u002Fspeed problems a working free-list doesn't have yet.\n","# \u002Fmemory-allocator-from-scratch\n\n## When to Use\n\n- Implementing `malloc`\u002F`free`\u002F`realloc` semantics from raw memory (e.g. over `mmap`\u002F`sbrk`, or a fixed byte array) for teaching, an embedded target, or a custom-runtime project.\n- Choosing between allocator strategies (bump, free-list, buddy, slab) for a specific workload and needing the actual tradeoffs, not just the names.\n- Debugging fragmentation, use-after-free, or double-free in a hand-rolled allocator.\n\n## Do NOT use for\n\n- Application-level memory management in a language with a GC or a mature allocator (JS, Python, Go, Java) — there is nothing to build here, use the runtime's allocator.\n- General performance profiling of memory usage — see `memory-leak-detection` and `profiling-benchmarking` instead.\n- Production allocator replacement — use jemalloc\u002Fmimalloc\u002Ftcmalloc; this skill is for understanding the mechanism, not shipping a faster malloc than decades of tuned production allocators.\n\n---\n\n## Strategy Decision\n\n```\nNeed the simplest possible allocator, never freeing individual objects?\n  → Bump allocator (Step 1) — O(1) alloc, no free, reset all at once\n\nNeed general alloc\u002Ffree of variable sizes, simplicity over raw speed?\n  → Free-list allocator (Step 2) — the \"classic malloc\" approach\n\nNeed to minimize external fragmentation with fast coalescing?\n  → Buddy allocator (Step 3) — power-of-2 sizes, easy merge, some internal waste\n\nNeed fast alloc\u002Ffree of many same-sized objects (e.g. a fixed struct)?\n  → Slab allocator (Step 4) — pre-carved fixed-size slots, near-zero overhead per alloc\n```\n\n## Step 1: Bump Allocator (baseline)\n\nSimplest possible allocator: keep one pointer to the next free byte, hand out `size` bytes and advance the pointer. No `free()` — the whole arena resets or is discarded at once (common in arena\u002Fregion allocators for a single request's lifetime, e.g. a per-frame game allocator or a per-HTTP-request arena).\n\n```\nalloc(size):\n  aligned = align_up(next_free, ALIGNMENT)\n  if aligned + size > arena_end: return OUT_OF_MEMORY\n  next_free = aligned + size\n  return aligned\n```\n\n## Step 2: Free-List Allocator\n\nThe mechanism behind classic `malloc`. Every allocated AND free block gets a small header before the returned pointer:\n\n```\nstruct BlockHeader {\n  size_t size;       \u002F\u002F payload size, not including header\n  bool   is_free;\n  BlockHeader* next; \u002F\u002F intrusive linked list of free blocks\n}\n```\n\n`alloc(size)`: walk the free list looking for a block big enough.\n- **First-fit**: take the first block that fits — fast, can fragment.\n- **Best-fit**: scan for the smallest block that fits — less waste per allocation, slower, can leave many tiny unusable fragments over time.\n- If the found block is much bigger than needed, **split** it: carve off the requested size, leave the remainder as a new (smaller) free block.\n\n`free(ptr)`: walk back from `ptr` to its header, mark `is_free = true`, then **coalesce** with adjacent free blocks (check the block immediately before and after in memory address order, merge if both are free) — without coalescing, freed memory fragments into unusable slivers over time even though total free bytes is fine.\n\n**Alignment**: most platforms require allocations aligned to 8 or 16 bytes (SIMD types need more). Round the requested size up to the alignment boundary before computing block size — an unaligned pointer returned to the caller can crash on some architectures (e.g. ARM strict alignment) or silently corrupt SIMD loads.\n\n## Step 3: Buddy Allocator\n\nOnly allocates in power-of-2 sizes. The whole arena starts as one free block of size `2^max`. To satisfy a request, repeatedly split the smallest available block in half (\"buddies\") until you reach the smallest power-of-2 that fits the request. To free, check if your buddy (computable directly from your address via XOR with the block size) is also free — if so, merge back into the parent block, and recurse the check upward.\n\nTradeoff vs free-list: coalescing is O(log n) and address-computable (no list walk needed to find the buddy), but every allocation rounds up to the next power of 2 — a 65-byte request costs 128 bytes (internal fragmentation).\n\n## Step 4: Slab Allocator\n\nFor a workload that allocates\u002Ffrees many objects of the SAME fixed size (e.g. kernel `task_struct`, a game's particle objects): pre-allocate a \"slab\" (a page or arena) already carved into fixed-size slots, and track free slots with a simple bitmap or intrusive free list of slot indices. Alloc and free are both O(1) with no header-walking or fragmentation concerns, since every slot is identical size.\n\n## What NOT to Do\n\n- Don't skip the header — without per-block metadata, `free()` has no way to know a block's size or its free-list neighbors.\n- Don't forget alignment — misaligned pointers are a portability bug that won't show up on every platform\u002Fcompiler, making it easy to ship broken and not notice.\n- Don't free() without coalescing adjacent blocks — a free-list allocator that never merges will eventually report \"out of memory\" while holding plenty of free (but fragmented) bytes.\n- Don't reach for buddy or slab allocators before a free-list works correctly — they solve fragmentation\u002Fspeed problems a working free-list doesn't have yet.\n",{"name":5,"origin":24,"license":15,"version":25,"description":7,"compatibility":26},"yana-ai — synthesized from classic allocator literature (K&R malloc, dlmalloc design notes, jemalloc\u002Ftcmalloc public design docs) and community from-scratch tutorials indexed in codecrafters-io\u002Fbuild-your-own-x","1.0.0","yana-ai >= 0.43.2","main","481dcd7dd2e288b9d627a2bd017db70e64e6c6fa","core\u002Fskills\u002Fmemory-allocator-from-scratch",2,"https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI","https:\u002F\u002Fyana.vutam.link\u002F","https:\u002F\u002Fgithub.com\u002FHoronomos-laps","https:\u002F\u002Fyana.vutam.link","An open-source governed runtime & execution environment for multi-agent AI systems.","2026-11-14 13:24:09",{"source":8,"skillName":5,"commands":38,"prompt":48,"zipAvailable":49},[39,42,45],{"tool":40,"command":41},"npx","npx skills add Horonomos-laps\u002FYana-AI --skill memory-allocator-from-scratch",{"tool":43,"command":44},"bunx","bunx skills add Horonomos-laps\u002FYana-AI --skill memory-allocator-from-scratch",{"tool":46,"command":47},"pnpm","pnpm dlx skills add Horonomos-laps\u002FYana-AI --skill memory-allocator-from-scratch","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fmemory-allocator-from-scratch\u002FSKILL.md",true,[],[52,60,67,75,83,91],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":56,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M735GKET5YVYKAY62W2P5YXB","openai--sentry--sentry","Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.","MIT","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fopenai--sentry--sentry\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M73DCAP83T17HY7SMGK7MGFE","ito-basket-compare","Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fito-basket-compare\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":71,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M734CYEMZFDR3KH6SW0JP8TD","implementing-network-traffic-baselining","Build network traffic baselines from NetFlow\u002FIPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly\u002Fdaily traffic pattern profiling","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":79,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M73ASZ6NJRJM44Z2P84NGQ3Q","detecting-evasion-techniques-in-endpoint-logs","Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":87,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M734AFNXD06Z78QRK0VKGT7Q","implementing-microsegmentation-with-guardicore","Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M736TK27QMCXK0DVCH25SJN5","ramdisk-tmpfs-patterns","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Framdisk-tmpfs-patterns\u002FSKILL.md",[],[]]