Memory allocation manager for the MIPS assembly language. Allows memory that has been marked as free to be reused in future calls to alloc.
This code was implemented and tested in MARS (MIPS Assembler and Runtime Simulator).
The purpose of this code was for my own enjoyment and to learn more about memory management. It is provided as is (although contributions are welcome)
and while it should save memory consumption for most programs this does come at the cost of additional executed instructions.
MemManagementList.asmprovides the key functionality for managing free/allocated/uinitialized memory.MemManager.asmthe source file which should be included when using the memory manager. Implementsallocandfree.
To use the memory manager the.asmfiles must be copied to the directory that contains yourMARS.jarfile.
Function to allocate new memory either using syscall 9 (to initialize memory on the heap) or by returning memory that was marked free.
Function which takes in the address of allocated memory and marks it as free (ready to be used again by a call to alloc).
The provided example sorts an array using recursive MergeSort. Additionally, code to plot the memory impact is provided.
To run the example copy the .asm files to the directory with your MARS.jar file.
standard_mergesort.asmprovides code to run mergesort using syscall 9 directly (syscall 9 allocates heap memory)managed_mergesort.asmprovides code to run mergesort using memory managment via calls toallocandfreestandard_impact.txtthe result of runningstandard_mergesort.asmmanaged_impact.txtthe result of runningmanaged_mergesort.asmplot_impact.pypython code to plot the impact dataImpact_Plot.pnga plot of the memory impact of standard and managed MergeSort