Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Custom Memory Allocator in C++

Overview

This project implements a custom memory allocator in C++ to demonstrate how dynamic memory management works internally. Instead of using built-in functions like malloc or new, this allocator manually manages memory and provides a simple visualization of allocation and deallocation.

Objective

  • Understand low-level memory management
  • Simulate allocation and deallocation of memory blocks
  • Study fragmentation and memory usage patterns

Features

  • Custom allocation and deallocation functions
  • Tracking of free and allocated memory blocks
  • Visualization of memory layout
  • Modular design with separate components
  • Build automation using Makefile

Project Structure

memory_allocator/
│── allocator.cpp
│── allocator.hpp
│── visualizer.cpp
│── visualizer.hpp
│── main.cpp
│── Makefile

How to Run

1. Clone the repository

git clone <your-repo-link>
cd memory_allocator

2. Compile the project

make

3. Run the program

./memory_allocator

Example Output

[Free Block: 1000 bytes]
Allocate 200 bytes
[Allocated: 200][Free: 800]

Allocate 300 bytes
[Allocated: 200][Allocated: 300][Free: 500]

Free 200 bytes
[Free: 200][Allocated: 300][Free: 500]

Concepts Used

  • Dynamic memory allocation
  • Pointers and manual memory handling
  • Fragmentation
  • Basic data structures for memory tracking

Future Improvements

  • Implement allocation strategies such as First Fit, Best Fit, and Worst Fit
  • Improve fragmentation handling
  • Add performance comparison with standard allocators
  • Extend visualization capabilities

What I Learned

  • Internal working of memory allocation
  • Challenges in managing memory efficiently
  • Importance of memory optimization in system-level programming

Conclusion

This project provides a practical understanding of how memory allocation works at a lower level and highlights the complexity behind commonly used high-level operations.

Author

KARUNISHA R

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages