Skip to content

SymphonyVR/symphony-memory-guard

Repository files navigation

Symphony Memory Guard

A high-performance, lightweight anti-crash and system stability tool for Windows, written in Rust.

It intelligently monitors system resources—including physical RAM and commit charge—to prevent system-wide freezes and crashes. By proactively trimming or terminating low-priority, resource-heavy processes during critical pressure, it ensures the OS remains responsive and stable even under extreme loads.

Why Symphony Memory Guard?

This tool was born out of frustration with the "hard freeze" and BSoD (Blue Screen of Death) scenarios that occur on Windows when virtual memory (Commit Charge) is exhausted—often due to limited disk space or aggressive multitasking.

Unlike Linux, which has a built-in kernel-level OOM (Out-of-Memory) Killer to sacrifice a process and save the system, Windows simply attempts to page out everything until the system becomes completely unresponsive, eventually forcing a hard reboot.

Symphony Memory Guard bridges this gap. Inspired by the Linux OOM Killer but tailored for the Windows architecture, it provides a user-space safety net that:

  1. Monitors global commit charge (the true limit of Windows memory).
  2. Identifies resource hogs that are safe to terminate.
  3. Intervenes before the system locks up, keeping your PC usable without a reboot.

Features

  • Anti-Crash Protection: Prevents the "hard freeze" that occurs when Windows runs out of commit charge or physical memory.
  • Intelligent Monitoring: Continuously tracks physical RAM and commit charge usage (system-wide memory commitment).
  • Dual-Phase Stability:
    • Trimming Phase: Proactively trims working sets of low-priority processes when memory usage is high (80%+).
    • Kill Phase: Terminates the most resource-heavy low-priority process when critical thresholds are reached (customizable or 95% commit charge).
  • SIMD Accelerated: Utilizes SIMD (SSE2, AVX2, AVX-512) for ultra-fast process scanning and string handling.
  • Smart Scoring System: Prioritizes processes based on memory usage, priority class, and user-defined whitelists/blacklists.
  • Tray Icon Integration:
    • Run in the background with a system tray icon.
    • Toggle "Run at Startup" directly from the tray menu.
    • Show/Hide the terminal window.
  • Single Instance: Ensures only one instance runs at a time.
  • Zero-Allocation Hot Path: Optimized to minimize memory allocation during monitoring cycles.
  • System-Driven Activation: Instead of aggressively polling resources, it leverages Windows LowMemoryResourceNotification to wait for the OS to signal actual memory pressure, minimizing idle CPU usage.

Installation

You can build the project from source. Ensure you have Rust installed.

# Clone the repository
git clone https://github.com/Symphony/symphony-memory-guard.git
cd symphony-memory-guard

# Build with optimizations (defaults to native CPU features)
cargo build --release

Pre-built Binaries (GitHub Actions)

This project uses GitHub Actions to automatically build optimized versions for different CPU architectures:

  • symphony-memory-guard-sse2.exe (Maximum compatibility)
  • symphony-memory-guard-avx2.exe (Modern CPUs)
  • symphony-memory-guard-avx512.exe (High-performance CPUs)

Usage

Run the executable directly. It will start in the background and appear in your system tray.

Command Line Arguments

Usage: symphony-memory-guard.exe [OPTIONS]

Options:
  -t, --threshold <THRESHOLD>  Memory usage threshold percentage to trigger kill (default: 90)
  -d, --dry-run                Simulate actions without killing processes
  -g, --gather                 Enable data gathering mode for metrics
  -h, --help                   Print help
  -V, --version                Print version

Tray Menu

  • Show/Hide Terminal: Toggle the visibility of the console window.
  • Run at Startup: Enable/disable automatic startup with Windows.
  • Quit: Exit the application.

Configuration

The application uses a smart scoring algorithm to determine which process to kill.

  • High Score: Higher chance of being killed (High memory usage, Idle/Below Normal priority).
  • Low Score: Lower chance of being killed:
    • Foreground App: The application you are currently using is highly protected.
    • Interactive Apps: Processes with visible windows are favored over background services.
    • Established Processes: Longer-running processes get a slight protection bonus to avoid losing work.
    • Whitelisted apps: Critical system processes and games are protected.
    • High Priority: Realtime and High priority classes are prioritized for stability.

Safety Mechanisms

  • Whitelists: Critical Windows processes (e.g., svchost.exe, csrss.exe, explorer.exe) are protected.
  • Self-Protection: The OOM Killer protects itself and minimizes its own memory footprint.

License

This project is dual-licensed under either:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

A high-performance, lightweight anti-crash and system stability tool for Windows that manages system-wide memory commitment.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

 
 
 

Contributors