Memory managment simulator in Java. Project for Operating Systems module (2nd year Computer Science).
This memory management structure will include a simulation of:
- malloc (first-fit allocation)
- free + coalescing functionality
- sbrk
- Simulate memory allocation (relatively close to the one present in C) using Java.
- Understand how metadata within memory blocks works.
- Implement a solid simulation and test it for edge cases
build and run shell scripts are provided to compile and run the project.
- cd into directory
./build.sh
./run.sh
This memory allocator system follows the following structure:
Request a chunk of memory of desired size (in bytes). will allocate a slightly bigger size for the chunk's metadata
Free a previously allocated memory chunk by its pointer and create a respective "free block"
Simulate "requesting" memory to the OS if the initial chunk (8192 bytes) is exceeded, creating a new array of memory of size x = smallest power of 2 larger than size.
The print function will run a series of tests with respective output structure and memory display, to understand and justify decisions for the implementation. Printed on terminal you will be able to read through the different tests with their descriptions.
- malloc will find a free spot using first-fit method.
- Adjacent free blocks in the same memory array will coalesce/merge. Initial memory or sbrk generated arrays will not coalesce with each other.