This project simulates browser tab memory behavior using classic page replacement algorithms from Operating Systems.
At a high level, it has three layers:
- Input and scenario setup
- Replacement algorithm execution
- Reporting and metrics visualization
Execution flow:
- The program reads total references, reference string, and frame count.
- You choose an algorithm from the menu: FIFO, LRU, or Optimal.
- The selected algorithm processes references step-by-step.
- The console prints tab openings/replacements and current memory frames.
- A summary reports total evictions and retention efficiency.
- Simulates tab replacement in constrained memory
- Supports FIFO, LRU, and Optimal algorithms
- Prints frame-by-frame state transitions
- Reports total tab evictions (page faults)
- Calculates tab retention efficiency
- Uses browser-tab names for human-friendly output
- Interactive menu-driven terminal program
- Clean modular structure (
src/+include/) - Browser-style page naming (
Gmail,YouTube,StackOverflow, etc.) - Reusable utility helpers for output and metrics
- Cross-platform Makefile with Windows/Linux handling
- Sample demonstration cases in
data/
smart-memory-manager/
├── Makefile
├── README.md
├── data/
│ └── sample_demonstration.txt
├── docs/
│ ├── references.txt
│ ├── Smart Memory Manager for Browser Tabs.pdf
│ └── SMART MEMORY MANAGER.pdf
├── include/
│ ├── fifo.h
│ ├── lru.h
│ ├── optimal.h
│ └── utils.h
└── src/
├── fifo.c
├── lru.c
├── main.c
├── optimal.c
└── utils.c
- C compiler (
gccrecommended) - Make utility (
make,mingw32-make, or equivalent) - Git
- Terminal (PowerShell, Bash, or Zsh)
- Visual Studio Code for editing and debugging
- WSL/MSYS2 on Windows for smoother GNU toolchain setup
git clone https://github.com/Code-Crew-Nexus/smart-memory-manager.git
cd smart-memory-managermake clean
makemingw32-make clean
mingw32-makegcc -Wall -Iinclude -o memory_manager src/main.c src/fifo.c src/lru.c src/optimal.c src/utils.cOn Windows, the output executable is usually memory_manager.exe.
.\memory_manager.exe./memory_managerThe program asks for:
- Number of tabs in reference string (
n) nspace-separated integers as references- Number of frames (tabs allowed in memory)
- Menu choice:
1FIFO2LRU3Optimal4Exit
Example input:
7
0 1 2 0 3 0 4
3
1
4
0-> Gmail1-> YouTube2-> StackOverflow3-> Twitter4-> LinkedIn5-> GeeksforGeeks6-> Reddit7-> WhatsApp Web
Any value outside this range maps to Unknown Tab.
- CLI entry point
- Reads input and handles algorithm menu loop
- Implements FIFO replacement using cyclic pointer
- Implements LRU replacement using last-used index tracking
- Implements Optimal replacement by checking farthest future use
- Maps page numbers to tab names
- Prints frame state after each reference
- Computes/display metrics
All algorithms process the same reference stream with limited frame capacity.
- Rule: evict the oldest loaded tab
- Complexity per reference:
$O(f)$ for frame search
- Rule: evict the least recently used tab
- Tracks recency index for each frame
- Complexity per reference:
$O(f)$
- Rule: evict the tab used farthest in the future (or never used again)
- Theoretical lower bound for evictions
- Complexity per reference can be up to
$O(f \cdot n)$ due to look-ahead scans
At the end of each algorithm run:
Total Tab Evictions(page faults)Tab Retention Efficiency
Formula used:
((totalPages - pageFaults) / totalPages) * 100
The Makefile includes optional redirection targets (fifo, lru, optimal) that refer to:
data/ref_string1.txtresults/output files
If you want to use those targets, create these resources first. Otherwise use interactive mode.
-
makenot recognized on Windows- Use
mingw32-makeor install GNU Make.
- Use
-
gccnot recognized- Install a GCC toolchain and restart terminal.
-
Executable not launching in PowerShell
- Run with
./prefix equivalent:.\memory_manager.exe.
- Run with
-
Unexpected tab labels
- Use references mainly in
0-7; others are shown asUnknown Tab.
- Use references mainly in
- Add batch input mode from file
- Add side-by-side algorithm comparison report
- Add automatic result export to
results/ - Add unit tests for replacement behavior
- Add runtime complexity benchmark section
This project was developed as part of the PBL initiative under Code-Crew-Nexus.
- M. Sai Krishna
- MD. Abdul Rayain
- Rishit Ghosh
- Yaram Karthik
Future contributors are welcome through issues and pull requests.