All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

Minimal Memory Allocator in C with sbrk and mmap Implementation

By

t9nzin

6mo ago· 3 min readenCode

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 pulled
A 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.
Snippet from the RSS feed
a minimal memory allocator in C. Contribute to t9nzin/memory development by creating an account on GitHub.

You might also wanna read