# ๐Ÿง  Memory Management Analyzer This project demonstrates how different memory allocation methods (`malloc`, `calloc`, and `mmap`) perform in terms of speed and memory usage in a simulated workload. --- ## ๐Ÿ“œ Description The program dynamically allocates and frees memory blocks of varying sizes, measuring: - Allocation and deallocation times. - Memory usage via `/proc/self/status` or `/proc/self/statm`. - Peak memory consumption during execution. It produces a report comparing performance across allocation methods. --- ## ๐Ÿš€ Features - **Dynamic Allocation Testing** โ€“ compares `malloc`, `calloc`, and `mmap`. - **Performance Metrics** โ€“ measures allocation/deallocation times. - **Memory Usage Tracking** โ€“ monitors real-time process memory usage. - **Optional Memory Leak Simulation** โ€“ detects unfreed memory using Valgrind. - **CLI Mode Selection** โ€“ choose allocator at runtime (`--malloc`, `--calloc`, `--mmap`). --- ## ๐Ÿ› ๏ธ Build ```bash make ``` --- ## โ–ถ๏ธ Run ```bash ./mem_analyzer --malloc ./mem_analyzer --calloc ./mem_analyzer --mmap ``` --- ## ๐Ÿงช Test & Debug ```bash make valgrind ``` --- ## ๐Ÿ“Š Example Output ``` Allocator: malloc Blocks: 10000 Average Allocation Time: 0.24 ฮผs Average Free Time: 0.18 ฮผs Peak Memory Usage: 2.5 MB ``` --- ## ๐Ÿ“‚ Project Structure ``` mem_analyzer/ โ”œโ”€โ”€ README.md โ”œโ”€โ”€ Makefile โ””โ”€โ”€ main.c ``` --- ## ๐Ÿ” Learning Objectives - Understand differences between `malloc`, `calloc`, and `mmap`. - Learn to measure memory usage through `/proc`. - Practice debugging memory errors with Valgrind. - Gain insight into memory allocation strategies in Linux. ---