An open API service indexing awesome lists of open source software.

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.

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.

---