Minimal Memory Allocator in C with sbrk and mmap Implementation
By
t9nzin
Hot, fresh, and worth queueing round the block for.
Summary
This article describes a minimal memory allocator written in C from scratch, using sbrk for small allocations and mmap for large allocations. The allocator includes optimizations like block splitting to reduce fragmentation and coalescing to merge adjacent free blocks. The project is not thread-safe and concurrent calls to malloc/free/realloc will cause undefined behavior. The author has also written a blog post explaining the step-by-step process behind creating this memory allocator project.
Key quotes
· 4 pulledA memory allocator written from scratch using sbrk for small allocations and mmap for large allocations.
It includes optimizations like block splitting to reduce fragmentation and coalescing to merge adjacent free blocks.
Please note that this allocator is not thread-safe. Concurrent calls to malloc/free/realloc will cause undefined behavior.
I've also written a blog post (~20 minute read) explaining step by step the process behind writing this memory allocator project.
You might also wanna read
Experimental Thread-Like Processes: Multiple Executables in Shared Address Space
The article describes an experimental GitHub repository called 'threadprocs' that implements thread-like processes, allowing multiple execut
CacheKit: High-Performance Cache Policies and Data Structures for Rust Systems
CacheKit is a Rust library providing high-performance cache replacement policies and supporting data structures for systems programming. It
Building a Redis-Compatible Key/Value Server in Zig with Static Memory Allocation
The article discusses the development of 'kv', a Redis-compatible key/value server implemented in Zig programming language, focusing on the
Advanced Borrow-Checker Concepts in Rust Programming: Exploring New Reference Types
This article explores advanced concepts in Rust programming language's borrow-checker system, proposing new reference types and algebraic st
Rue: An Early-Stage Systems Programming Language Research Project for Memory Safety
Rue is an early-stage research project for a systems programming language that aims to provide memory safety without garbage collection, sim
Buffer Size Considerations and Safety Implications in Zig's New I/O Writer Implementation
The article discusses programming considerations for Zig's new std.Io.Reader and Writer interfaces, focusing on buffer size decisions and sa
