https://github.com/opikadash/memory-management-simulator
C++ Memory Management Simulator implementing First-Fit and Best-Fit allocation strategies with support for random stress testing, memory state persistence, CSV export for visualization, and benchmarking via GoogleTest.
https://github.com/opikadash/memory-management-simulator
best-fit cpp data-structures first-fit googletest makefile operating-systems simulation
Last synced: 6 months ago
JSON representation
C++ Memory Management Simulator implementing First-Fit and Best-Fit allocation strategies with support for random stress testing, memory state persistence, CSV export for visualization, and benchmarking via GoogleTest.
- Host: GitHub
- URL: https://github.com/opikadash/memory-management-simulator
- Owner: Opikadash
- Created: 2025-06-26T03:07:00.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-06-26T18:20:06.000Z (6 months ago)
- Last Synced: 2025-06-26T19:26:28.807Z (6 months ago)
- Topics: best-fit, cpp, data-structures, first-fit, googletest, makefile, operating-systems, simulation
- Language: C++
- Homepage:
- Size: 37.1 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
```markdown
# ๐ง Memory Management Simulator
๐ A modern C++ simulator that models memory allocation using **First-Fit** and **Best-Fit** strategies. Designed to emulate real-world memory management in operating systems, this project features a runtime strategy switch, stress testing, data export, and optional unit testing via GoogleTest.
---
## โจ Features
- ๐ **Allocation Strategies**: Switch between First-Fit and Best-Fit at runtime
- ๐ **Exportable Logs**: Memory block states saved to CSV for analysis
- ๐งช **Random Stress Testing**: Dynamically simulate fragmentation and load
- ๐พ **Save/Load State**: Resume memory states using file I/O
- ๐ง **CLI-Based UI**: Intuitive and interactive user interface
- โ
**Unit Tests**: Written using GoogleTest (via `vcpkg`)
- ๐งต **Modular Design**: Clear separation of core logic and utilities
---
## ๐ง Getting Started
### ๐ฆ Prerequisites
- CMake โฅ 3.16
- C++17 compiler (MSVC, GCC, or Clang)
- [vcpkg](https://github.com/microsoft/vcpkg) (for dependency management)
### ๐ ๏ธ Build Instructions
```bash
git clone https://github.com/Opikadash/memory-management-simulator.git
cd MemoryManagementSimulator
cmake -B build
cmake --build build
````
### โ
Run the Simulator
```bash
./build/simulator
```
---
## ๐งช Running Unit Tests (Optional)
Install GoogleTest using [vcpkg](https://github.com/microsoft/vcpkg):
```bash
vcpkg install gtest
```
Then build with tests:
```bash
cmake -DENABLE_TESTING=ON -B build
cmake --build build
cd build && ctest
```
---
## ๐ Visualize Memory Logs
```bash
python scripts/visualize_memory.py data/memory_log.csv
```
Creates a time-series graph of allocation and fragmentation over time.
---
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
---
---
## โ
`CMakeLists.txt`
```cmake
cmake_minimum_required(VERSION 3.16)
project(MemoryManagementSimulator)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Include header files
include_directories(include)
# Build core simulator
add_executable(simulator
src/main.cpp
src/memory_manager.cpp
)
# GoogleTest-based unit tests
option(ENABLE_TESTING "Enable Unit Tests" ON)
if(ENABLE_TESTING)
enable_testing()
find_package(GTest CONFIG REQUIRED)
add_executable(simulator_tests
tests/test_memory_manager.cpp
src/memory_manager.cpp
)
target_include_directories(simulator_tests PRIVATE include)
target_link_libraries(simulator_tests GTest::gtest_main)
include(GoogleTest)
gtest_discover_tests(simulator_tests)
endif()
````
---
---
## โ
`LICENSE` (MIT)
```text
MIT License
Copyright (c) 2025 [Opika]
Permission is hereby granted, free of charge, to any person obtaining a copy...
```
---
```
> ๐ Make sure GoogleTest is globally installed or built locally and linked properly.
---