Skip to content

About

A fun memory visualiser.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

Live Memory Visualiser - README

Description:

This is a live memory visualiser written in C for Windows. It tracks allocations and deallocations in a simulated heap, logs the memory state to a JSON file, and visualises it in real-time using an animated HTML page.

Features:

  1. Continuous memory tracking:
    • Allocations and deallocations are logged to memory_log.json every 0.5 seconds.
  2. Interactive memory simulation:
    • Press 'a' to allocate a 32B block.
    • Press 'f' to free the last unfreed block.
    • Press 'q' to quit the programme.
  3. Animated HTML visualisation:
    • Uses CSS and JavaScript to display blocks with height proportional to size.
    • Green blocks = allocated, Red blocks = freed.
  4. Safe memory cleanup:
    • All memory is freed when the programme exits.
  5. Optional automatic mode:
    • The programme can be configured to randomly allocate/free blocks for demonstration.

Safety Notes:

  • Unlimited allocations can consume large amounts of memory. Avoid pressing 'a' excessively.
  • File writing occurs every 0.5 seconds to memory_log.json. Ensure the file is not locked by another programme.
  • If the programme is terminated abruptly, memory is released by Windows but JSON may not be fully updated.
  • Designed for Windows; does not use POSIX sockets.

Requirements:

  • Windows OS
  • GCC (e.g., via MinGW) for compilation
  • Python 3 (for running a local HTTP server to view HTML)
  • Web browser (Chrome, Edge, Firefox, etc.)

Files:

  1. Memory_Visualiser_LoggerV2.c - C programme to simulate memory allocations/frees and log to JSON.
  2. Mem_VisualiserV2.html - HTML + JS file for animated visualisation.
  3. Memory_Visualiser_V2.exe - Compiled Windows executable (optional; source code recommended).
  4. memory_log.json - JSON file generated by the C programme.
  5. README.txt - this file.

Instructions to Run:

Step 1: Compile the C programme

Open PowerShell or Command Prompt in the folder containing the files:

gcc Memory_Visualiser_LoggerV2.c -o Memory_Visualiser_V2.exe

Step 2: Run the C programme

.\Memory_Visualiser_V2.exe

  • The programme will run indefinitely.
  • Use keys:
    • 'a' → allocate 32B memory block
    • 'f' → free the last unfreed block
    • 'q' → quit the programme

Step 3: Serve files for the HTML visualiser

Open another terminal in the same folder and run:

python3 -m http.server 8000

This will serve the folder at http://localhost:8000

Step 4: Open the HTML visualisation

Open your web browser and navigate to:

http://localhost:8000/Mem_VisualiserV2.html

  • The page will fetch memory_log.json every second.
  • Blocks will animate as memory is allocated or freed.

Optional: Automatic Mode

You can modify Memory_Visualiser_LoggerV2.c to randomly allocate/free blocks in a loop instead of manual keypresses. This will simulate heap activity automatically and continuously.

Notes:

  • The JSON file is overwritten on every update.
  • The HTML visualisation can be refreshed manually or will update automatically if polling is enabled.
  • Scaling factor in the HTML file may be adjusted for better visibility of block heights.

Licence:

This is provided for educational purposes. Use at your own risk.

End of README

About

A fun memory visualiser.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages