My Malloc is a low-level C project where you implement a custom memory allocator, mimicking the behavior of the standard malloc
/free
interface.
This academic project focuses on understanding memory layout, pointer arithmetic, and heap management at the OS level.
🔍 What It Does
-
Heap Initialization:
- A custom heap is initialized using
sbrk()
or similar system calls. - A header/footer structure is defined to manage each memory block.
- A custom heap is initialized using
-
Memory Allocation (
my_malloc
):- Implements first-fit or best-fit strategies to find suitable free blocks.
- Handles block splitting when an allocation leaves excess space.
-
Free List Management:
- Maintains a linked list of free blocks for efficient lookup and reuse.
- Optimized for low fragmentation and allocation speed.
🧠 Key Concepts Covered
- Manual memory management
- Data alignment and padding
- Fragmentation (internal/external)
- Pointer manipulation & low-level bitwise operations
- Performance vs. memory trade-offs in allocator design
📚 Context
This project is part of the Systems Programming module at EPITA, designed to build a deep understanding of how memory management works under the hood in C and Unix-based systems.
By reimplementing malloc
, students get hands-on experience with the kind of mechanisms used in real-world allocators like dlmalloc
or jemalloc
, on a smaller, didactic scale.