Allocatron is a memory management library implemented in C. It provides memory allocation and deallocation functions similar to malloc and free, with support for different allocation strategies such as First Fit (FF), Next Fit (NF), Best Fit (BF), and Worst Fit (WF).
- Custom memory allocation functions (
malloc,free,calloc,realloc) - Support for different allocation strategies (First Fit, Next Fit, Best Fit, Worst Fit)
- Memory statistics tracking (mallocs, frees, reuses, grows, splits, coalesces, blocks, requested, max heap)
- Easy integration into C projects
To build and use the Allocatron, you need:
- GCC (GNU Compiler Collection)
- Unix-like operating system (Linux preferred)
Clone the repository and navigate to the project directory:
git clone https://github.com/pxs4528/mallocCompile the memory allocator libraries using the provided Makefile:
makeTo use the custom memory allocator in your C project, follow these steps:
-
Include the appropriate library in your source code:
lib/libmalloc-ff.sofor First Fitlib/libmalloc-nf.sofor Next Fitlib/libmalloc-bf.sofor Best Fitlib/libmalloc-wf.sofor Worst Fit
-
Use the custom memory allocation functions (
malloc,free,calloc,realloc) in your code as you would with the standard C library. -
Compile your project by specifying the library and include paths, for example:
$ env LD_PRELOAD=lib/libmalloc-ff.so tests/ffnf
-
Run your program, and the custom memory allocator will manage memory allocation and deallocation based on the selected strategy.
The custom memory allocator supports various allocation strategies, which you can choose by linking with the appropriate library:
- First Fit (FF):
libmalloc-ff.so - Next Fit (NF):
libmalloc-nf.so - Best Fit (BF):
libmalloc-bf.so - Worst Fit (WF):
libmalloc-wf.so
You can switch between strategies by selecting the corresponding library during compilation.
Contributions to this project are welcome! If you find a bug, have an improvement in mind, or want to add new features, please open an issue or create a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
Allocatron is developed and maintained by Parth Sharma.