battery-pack-rs/battery-pack/memory-allocator
Claude Code and agent skill by battery-pack-rs/battery-pack
- community
Checking that the SKILL.md file is still in the repository.
Choosing and profiling the global allocator (jemalloc, mimalloc, system) in the backend-service `service` template
Install
npx vskill@latest install battery-pack-rs/battery-pack/memory-allocatorSKILL.md
Memory Allocator
The allocator choice at generation time sets the #[global_allocator] in src/main.rs. It is a build-time decision, not a runtime knob.
Which one
- jemalloc (
tikv-jemallocator, the default): a mature, arena-based allocator with strong fragmentation control and steady RSS under sustained multi-threaded load, plus deep runtime tuning (MALLOC_CONF) and built-in heap profiling. The cost is a higher idle baseline and a larger binary. It does not build on MSVC, so both the dependency and the#[global_allocator]static are gated withcfg(not(target_env = "msvc")). - mimalloc: newer and smaller, with very fast small-allocation paths and typically lower memory footprint, but far fewer tuning knobs and less of a track record under sustained server load. A strong pick for allocation-heavy workloads or a Windows-MSVC target.
- system: the platform allocator (glibc on Linux). No extra dependency and the simplest build, but glibc's per-thread arenas can grow RSS under heavy multi-threaded churn. Use it for low-concurrency services, when you want zero added dependencies, or as a baseline when isolating an allocator-sensitive bug.
jemalloc is the default; switch only after measuring your workload.
Heap profiling with dial9
When the dial9 feature is on, the global allocator is wrapped in Dial9Allocator, which is a passthrough until a memory profiler is installed in main. Set DIAL9_MEMORY_PROFILE_ENABLED=true to install it at startup and capture allocation samples. dial9's own tooling reads the resulting profile; this skill does not cover that analysis.
Invariants
- Keep the
cfg(not(target_env = "msvc"))gate on both the jemalloc dependency and its static, or Windows builds break. - There is exactly one
#[global_allocator]. Whendial9is on, the allocator must be theDial9Allocatorwrapper around your chosen allocator, not the bare allocator, or heap profiling silently records nothing.
References
- jemalloc: https://docs.rs/tikv-jemallocator, mimalloc: https://docs.rs/mimalloc
- Profiling analysis and the viewer: see the dial9 references in the
telemetryskill.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingbattery-packs/backend-service-battery-pack/skills/memory-allocator/SKILL.md
Popularity
- Repository stars
- 78
- Repository forks
- 12
- 7-day trend score
- 22
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/battery-pack-rs/battery-pack/memory-allocator)