This simulator helps computer science students and enthusiasts understand memory allocation visually and interactively. Inspired by CS106B's dynamic memory lecture.
- User Input for Processes: Users can add processes by specifying memory size and duration.
- Best-Fit Allocation: Allocates memory using the Best-Fit strategy, minimizing fragmentation.
- Dynamic Partitioning: Memory blocks are split as needed for optimal use.
- Simulated Clock: Background clock manages each process's lifetime, freeing memory when done.
- Doubly Linked List Representation: Memory is managed with a doubly linked list for efficient operations.
- Compaction: Merges free blocks into one to reduce fragmentation.
- JavaScript: Core logic for memory management.
- HTML/CSS: Front-end for visualizing memory allocation.
- Process Creation: Users create processes with a specified size and duration.
- Memory Blocks: Memory is divided into blocks (
MemControlBlock
), which can be allocated or partitioned. - Allocation Algorithm: Uses Best-Fit to allocate the smallest block that fits a process.
- Simulated Clock: Manages process duration and frees memory when time expires.
- Compaction: Option to merge all free blocks into one to reduce fragmentation.
- Process Class: Represents processes needing memory.
- MemControlBlock Class: Represents memory blocks, linked in a doubly linked list.
- Heap Class: Manages memory allocation, deallocation, and compaction.
- Front-End Interaction: Users interact through a form, with visual updates showing block availability.
- Open the HTML file in a web browser.
- Use the form to add processes by specifying size and duration.
- Observe memory allocation, deallocation, and compaction.
- Use checkboxes to enable First-Fit, Fragmentation Display, or Compaction.
- Fragmentation: Visualize internal and external fragmentation challenges.
- Best-Fit Strategy: Learn about advantages and limitations of Best-Fit.
- Compaction: See how compaction helps reduce fragmentation.
- More Allocation Strategies: Add First-Fit and Worst-Fit for comparison.
- Improved Visualization: Add animations or detailed memory usage graphs.
- Metrics: Show memory utilization and average wait time for better insights.