Memory management is a fundamental aspect of operating systems, crucial for optimizing performance and resource utilization. This project, Dynamic-Memory-Allocator-Simulator, is a C++ application designed to simulate and compare different memory allocation techniques: First-Fit, Best-Fit, and Worst-Fit. By visualizing how these algorithms allocate and deallocate memory, users can gain a deeper understanding of their memory usage and fragmentation efficiency.
- Dynamic Technique Selection: Choose between First-Fit, Best-Fit, and Worst-Fit allocation techniques at runtime.
- Customizable Memory Partitions: Enter and modify memory partition sizes dynamically during execution.
- Visual Representation: View memory blocks and their allocation status through tables and color-coded indicators.
- Performance Metrics: Measure and compare the efficiency of each allocation technique regarding memory usage and fragmentation.
- Deallocation Support: Simulate real-world scenarios by freeing up allocated memory blocks.
DEMO.mp4
- C++ Compiler: Ensure you have a C++17 compatible compiler installed (e.g.,
g++,clang++). - CMake: Recommended for building the project.
- Windows OS: The current implementation utilizes Windows-specific libraries for console handling.
-
Clone the Repository
git clone https://github.com/3bbaas/Dynamic-Memory-Allocator-Simulator.git
-
Configure Cmake file
cmake_minimum_required(VERSION 3.30) project(Dynamic_Memory_Allocator_Simulator) set(CMAKE_CXX_STANDARD 23) include_directories(include) include_directories(include/Allocation) add_executable(Dynamic_Memory_Allocator_Simulator src/Allocation/BestFit.cpp src/Allocation/FirstFit.cpp src/Allocation/WorstFit.cpp src/Application.cpp src/ConsoleHandler.cpp src/UI.cpp main.cpp)
-
Navigate to the Project Directory
cd Dynamic-Memory-Allocator-Simulator -
Build the Project
- Using Cmake
mkdir build cd build cmake .. make - Alternatively, compile manually:
g++ main.cpp src/*.cpp src/Allocation/*.cpp -o MemoryAllocatorSimulator
- Using Cmake
-
Run the Application
./MemoryAllocatorSimulator
Upon running the application, you will be greeted with a dynamic console interface where you can:
-
Update Partition Values (Admins Only)
- Requires admin credentials to modify memory partition sizes.
-
Use Default Partitions
- Proceed with predefined memory partitions or enter custom ones.
-
Choose Allocation Technique
- Select between First-Fit, Best-Fit, and Worst-Fit to allocate memory for processes.
-
Allocate and Deallocate Processes
- Add new processes with specific memory requirements.
- Free up memory by deallocating existing processes.
-
Visualize Memory Allocation
- View memory blocks as tables with color-coded statuses indicating allocated or free spaces.
Dynamic-Memory-Allocator-Simulator/
├── data/
│ └── partitions
├── include/
│ ├── Allocation/
│ │ ├── AllocationTechnique.h
│ │ ├── BestFit.h
│ │ ├── FirstFit.h
│ │ └── WorstFit.h
│ ├── Application.h
│ ├── ColorCode.h
│ ├── ConsoleHandler.h
│ └── UI.h
├── src/
│ ├── Allocation/
│ │ ├── BestFit.cpp
│ │ ├── FirstFit.cpp
│ │ └── WorstFit.cpp
│ ├── Application.cpp
│ ├── ConsoleHandler.cpp
│ └── UI.cpp
├── main.cpp
├── README.md
└── LICENSE
main.cpp: Initializes the application.include/: Header files containing class declarations.Allocation/: Contains different allocation technique classes.src/: Source files containing class definitions and implementations.data/: Directory for storing memory partition data.
Contributions are welcome! Please create an issue or submit a pull request if you want to add a feature or improve the code.
This project is licensed under the MIT License.
