A custom dynamic memory allocator implemented in C++ on Linux, designed to explore low-level memory management without relying on standard memory allocation functions.
The implementation demonstrates how memory is requested from the operating system, tracked using metadata, and reused through allocation and deallocation mechanisms.
A short demonstration of dynamic memory allocation, deallocation, and memory reuse using my custom C++ allocator.
- Implemented custom memory allocation functions.
- Used
sbrkfor heap memory allocation. - Managed allocation requests without standard allocation functions.
- Tracked allocated and free memory blocks using metadata.
- Implemented reuse of previously freed blocks.
- Managed memory blocks using linked structures.
- Implemented buddy-based memory allocation.
- Supported memory block splitting and merging.
- Managed memory reuse through block organization.
- Used
mmapandmunmapfor large allocations. - Worked with low-level Linux memory management mechanisms.
| Technology | Purpose |
|---|---|
| C++ | Core implementation |
| Linux | Execution environment |
| sbrk | Heap memory allocation |
| mmap / munmap | Memory mapping |
| Buddy Allocation | Block splitting and merging |
memory-allocator/
├── malloc_1.cpp
├── malloc_2.cpp
├── malloc_3.cpp
└── README.md
malloc_1.cpp— Basic dynamic memory allocation.malloc_2.cpp— Metadata-based allocation, block reuse, and memory tracking.malloc_3.cpp— Extended allocator with buddy allocation and advanced memory management.
This project explores several important systems programming concepts:
- Dynamic memory allocation
- Heap management
- Memory block metadata
- Memory reuse and fragmentation
- Buddy allocation
- Pointer arithmetic
- Linux memory management
Language: C++
Platform: Linux
Compiler: g++
The repository contains allocator implementations intended to be compiled and used with a compatible test program.
