Project 2: Custom Memory Allocator
The goal of this project is to develop a custom memory management library that enhances the efficiency of memory allocation and deallocation processes. By implementing efficient algorithms and data structures, this allocator should cover existing mechanisms in the standard memory allocatiors such as malloc()
and free()
in an efficient way, by addressing issues like fragmentation and inefficient memory usage. The project will explore various allocation strategies to achieve a balance between performance and memory efficiency while ensuring compliance with alignment requirements. To this end, you have to implement your own version of memory management functionalities, with respect to their documentation in the manual (e.g., man malloc
):
malloc()
: Allocates a block of memory of the specified size and returns a pointer to the beginning of the block. You should implement three strategies: Best Fit, First Fit, and Next Fit.free()
: Deallocates the memory block pointed to by ptr, making it available for future allocations. Implementation of the free function should support the merging of adjacent free blocks, reducing fragmentation.calloc()
: Allocates the block of memory of the specified size, initializing it with zero, and returns a pointer to the beginning of the block.realloc()
: Resizes the memory block pointed to by ptr to the new size, potentially relocating it if needed.
Testing
- You should not use existing
malloc
/free
functions. You must write your own version. It is allowed to usebrk
/sbrk
. - Your test cases should cover the different aspects mentioned in the description. You should use
LD_PRELOAD
to test your library and run the same program with different strategies. - Start with implementing one strategy and a deallocation of the memory block. Then add the other required functions/strategies.
- Write a short report and evaluate the impact of each strategy on performance and memory usage compared to existing Linux memory management. Your report should be one pdf file. There is no limit on the page number.
General Rules
- The project is due on the 09.02.2025, 23:59 (hard deadline).
- The presentation date will be from 10.02.2025 to 14.02.2025, depending on your time table (send a message on Element to set a time).
- Attendance is mandatory on presentation day.
- Your grade will depend on the features implemented, design choices, quality of implementation, and your argumentation during the presentation.
- The projects should be implemented in C.
- The evaluation is not All-or-Nothing, so start with simple steps.
- Both members of the group are required to present the code.
- You are (obviously) allowed to implement more features, but you should prioritize the features we ask for!