بنقرة واحدة
memory-allocator
Implement memory allocators for efficient dynamic memory management in language runtimes.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Implement memory allocators for efficient dynamic memory management in language runtimes.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Implement abstract machines for defining and executing operational semantics of programming languages.
Implements alias and points-to analysis for pointer programs. Use for: (1) Optimizing compilers, (2) Verifying memory safety, (3) Program understanding, (4) Parallelization.
Define program meaning through logical assertions and proof rules (Hoare logic).
Transforms closures to explicit environments. Use when: (1) Implementing functional languages, (2) Building compilers, (3) Understanding closures.
Implements common subexpression elimination (CSE). Use when: (1) Building compilers, (2) Optimizing code, (3) Program analysis.
Implements general dataflow analysis framework. Use when: (1) Building compilers, (2) Static analysis tools, (3) Program verification.
| name | memory-allocator |
| description | Implement memory allocators for efficient dynamic memory management in language runtimes. |
| version | 1.0.0 |
| tags | ["runtime","memory","systems","pldi"] |
| difficulty | advanced |
| languages | ["c","rust","c++"] |
| dependencies | ["garbage-collector-implementer"] |
Memory allocators manage dynamic memory allocation and deallocation, a critical component of language runtimes. Different allocation strategies optimize for different workloads.
| Concept | Description |
|---|---|
| Block | Contiguous memory region |
| Fragmentation | Wasted space (internal or external) |
| Free List | Linked list of free blocks |
| Coalescing | Merge adjacent free blocks |
| Slab | Pre-allocated block for fixed-size objects |
garbage-collector-implementer - Automatic memory managementescape-analysis - Optimize allocationjit-compiler-builder - JIT allocation| Reference | Why It Matters |
|---|---|
| Wilson et al., "Dynamic Storage Allocation" (1994) | Survey of algorithms |
| Bonwick, "The Linux Slab Allocator" (USENIX 1994) | Linux slab allocator |
| Berger, McKinley, Blumofe & Wilson, "Hoard: A Scalable Memory Allocator for Multithreaded Applications" (ASPLOS 2000) | Scalable multicore allocator |
| Approach | Pros | Cons |
|---|---|---|
| Bump pointer | Very fast | Cannot free individually |
| Free list | Can free | Fragmentation |
| Slab | No fragmentation | Fixed size only |
A high-quality implementation should have:
| Criterion | What to Look For |
|---|---|
| Correctness | No corruption, double-free safe |
| Efficiency | Low allocation overhead |
| Fragmentation | Reasonable memory usage |
| Safety | Bounds checking |
✅ Good: Correct, efficient, handles edge cases ⚠️ Warning: Fragmentation issues ❌ Bad: Memory corruption, crashes
Real-world memory allocators:
| Tool | Why It Matters |
|---|---|
| jemalloc | Facebook allocator |
| tcmalloc | Google allocator |
| Hoard | Scalable allocator |
| snmalloc | Microsoft's allocator |
| RPMalloc | Fast allocator |
Current allocator research:
| Direction | Key Papers | Challenge |
|---|---|---|
| Scalable | "Scalable Allocators" | Multi-core |
| NUMA | "NUMA-aware" | Memory hierarchy |
| Large | "Large allocators" | Big data |
Common allocator bugs:
| Pitfall | Real Example | Prevention |
|---|---|---|
| Fragmentation | Memory fragmentation | Slab alloc |
| Thread contention | Lock contention | Per-thread pools |
| Memory | Memory corruption | Bounds checking |