custom-allocators

custom-allocators is a skill for Claude Code, Codex from mohitmishra786/low-level-dev-skills. It costs 65 tokens per session (1,788 once invoked), scanned A, original, MIT.

Guidance for designing and tuning memory allocators, which decide how a program reserves and releases memory.

In plain words
What is it for?
Use it to build pool, slab, arena, or buddy allocators; tune jemalloc or mimalloc; implement Rust's GlobalAlloc; and benchmark allocation speed and delays.
Why use it?
It helps when ordinary memory allocation causes slowdowns, memory fragmentation, or unsuitable behavior for embedded and latency-sensitive programs.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/mohitmishra786/low-level-dev-skills/custom-allocators
Any agent
npx skills add mohitmishra786/low-level-dev-skills --skill custom-allocators
Clone the repo
git clone --depth 1 https://github.com/mohitmishra786/low-level-dev-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for custom-allocators

README.md
[![agentmods](https://agentmods.dev/badge/skills/mohitmishra786/low-level-dev-skills/custom-allocators.svg)](https://agentmods.dev/skills/mohitmishra786/low-level-dev-skills/custom-allocators)
Your own site
<a href="https://agentmods.dev/skills/mohitmishra786/low-level-dev-skills/custom-allocators"><img src="https://agentmods.dev/badge/skills/mohitmishra786/low-level-dev-skills/custom-allocators.svg" alt="Measured on agentmods" height="20"></a>
Per session 65 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,788 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00065 $0.01788
Opus 5 $0.00032 $0.00894
Sonnet 5 $0.00013 $0.00358
Haiku 4.5 $0.00006 $0.00179

Measured 6d ago against content hash 5ca506df5f36, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

custom-allocators scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/allocators/custom-allocators/SKILL.md · 237 lines

How it starts

The opening of the file, as written. The whole thing — 237 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Custom Allocators

Purpose

Guide agents through memory allocator design and tuning: pool/slab/arena/buddy taxonomy, jemalloc internals and MALLOC_CONF, mimalloc design, tcmalloc thread-caching, writing a simple pool allocator in C, Rust GlobalAlloc trait, fragmentation metrics, and benchmarking.

When to Use

  • Replacing malloc for latency-sensitive or embedded workloads
  • Tuning jemalloc/mimalloc for server heap behavior
  • Implementing arena allocation for request-scoped or frame-based lifetimes
  • Writing a Rust custom global allocator for no_std or performance
  • Diagnosing heap fragmentation (internal vs external)
  • Benchmarking allocator throughput and latency

Workflow

1. Allocator taxonomy

Allocator types
├── Pool/fixed-size — O(1) alloc/free, fixed block sizes
├── Slab — kernel-style, cache-friendly size classes
├── Arena/bump — fast alloc, bulk free (reset arena)
├── Buddy — power-of-two blocks, low fragmentation for large allocs
└── General (malloc) — jemalloc, mimalloc, tcmalloc

2. Simple pool allocator in C

#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>

typedef struct pool_block {
    struct pool_block *next;
} pool_block_t;

typedef struct {
    void   *memory;
    size_t  block_size;
    size_t  num_blocks;
    pool_block_t *free_list;
} pool_t;

int pool_init(pool_t *p, size_t block_size, size_t num_blocks) {
    p->block_size = block_size < sizeof(pool_block_t) ?
        sizeof(pool_block_t) : block_size;
    p->num_blocks = num_blocks;
    p->memory = aligned_alloc(64, p->block_size * num_blocks);
    if (!p->memory) return -1;
    p->free_list = NULL;
    for (size_t i = 0; i < num_blocks; i++) {
        pool_block_t *blk = (pool_block_t *)((char *)p->memory + i * p->block_size);
        blk->next = p->free_list;
        p->free_list = blk;
    }
    return 0;
}

void *pool_alloc(pool_t *p) {
    if (!p->free_list) return NULL;
    pool_block_t *blk = p->free_list;
    p->free_list = blk->next;
    return blk;
}

void pool_free(pool_t *p, void *ptr) {
    pool_block_t *blk = (pool_block_t *)ptr;
    blk->next = p->free_list;
    p->free_list = blk;
}

Read the full file on GitHub · 237 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 237 lines · 65 tokens per session scan A 5ca506df5f36

Subscribe to this mod's changes

custom-allocators is a skill published in the GitHub repository mohitmishra786/low-level-dev-skills (195 stars, last pushed 2mo ago), licensed MIT. It adds 65 tokens to every session and 1,788 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

ecommerce-growth-strategy

E-commerce growth strategy advisor. Diagnoses current business health using unit economics (CAC, LTV, AOV, contribution margin), identifies the highest-impact growth opportunities across 5 levers (traffic, conversion, AOV, retention, expansion), and builds a prioritized 90-day growth roadmap. Uses the Ansoff Matrix…

nexscope-ai/eCommerce-Skills · 175 tokens

ecommerce-ppc-strategy-planner

Cross-platform PPC strategy planner for ecommerce businesses. Analyzes your product and margins, recommends the right advertising platforms (Google Ads, Meta Ads, TikTok Ads), calculates ROAS targets, allocates budget across channels, and generates platform-specific campaign briefs with ad copy and creative direction.…

nexscope-ai/eCommerce-Skills · 122 tokens

ecommerce-marketing-strategy-builder

Full-stack e-commerce marketing strategy builder. Analyzes your product, market, and competitors, then builds a complete omnichannel marketing plan covering paid ads, SEO, email/SMS, content marketing, social media, influencer partnerships, and referral programs. Includes target audience persona, competitive…

nexscope-ai/eCommerce-Skills · 112 tokens

warehouse-optimization

E-commerce warehouse and inventory optimization advisor. Analyzes inventory health, calculates safety stock and reorder points, performs ABC analysis, evaluates fulfillment costs, and provides actionable recommendations for improving efficiency. Supports all major fulfillment models: Self-fulfillment, Amazon FBA/FBM…

nexscope-ai/eCommerce-Skills · 132 tokens

competitor-price-analysis

Competitor pricing strategy analysis and market positioning. Price mapping, pricing gaps identification, elasticity signals evaluation, and strategic pricing optimization. Use when the user asks about competitor pricing, price analysis, pricing strategy, or competitive pricing research.

nexscope-ai/eCommerce-Skills · 50 tokens

supply-chain-optimization-tiktok

Supply Chain Bottleneck Analyzer for TikTok Shop sellers. Diagnose cash flow, inventory turnover, affiliate commissions, and return rates. Includes FBT cost analysis, influencer payout optimization, and viral product lifecycle management. No API key required for basic analysis.

nexscope-ai/eCommerce-Skills · 57 tokens