DEV Community

Jojin John
Jojin John

Posted on

How I Built a Real-Time Windows RAM Optimizer in Rust & Tauri v2

Many memory cleaner utilities on Windows rely on placebo tricks—forcing artificial allocation spikes that trigger Windows pageouts while causing heavy system stutter.

To solve this, I built RAMGuard Pro: a lightweight, high-performance desktop memory reclamation utility powered by Rust, Tauri v2, and React.


🛠️ How It Works Under the Hood

RAMGuard Pro bypasses placebos and interacts directly with native Windows NT kernel APIs:

1. Working-Set Trimming (EmptyWorkingSet)

The engine iterates over process handles and calls EmptyWorkingSet via the Windows PSAPI library. This instructs the OS memory manager to trim unreferenced working-set pages safely into standby memory.

2. Standby Memory Purging (NtSetSystemInformation)

To purge standby memory caches (similar to Sysinternals RAMMap), RAMGuard Pro calls the undocumented but stable NtSetSystemInformation kernel API:

  • Pass 1: Executes MemoryFlushModifiedList (Command 3) to flush dirty cached pages to disk.
  • Pass 2: Executes MemoryPurgeStandbyList (Command 4) to release all standby memory.

3. OS Core Protection Shield

To prevent blue screens or forced logouts, RAMGuard Pro includes a hard-coded security shield that excludes core Windows OS processes (system, csrss.exe, lsass.exe, explorer.exe, dwm.exe, etc.) from ever being trimmed or ended.


🚀 Features & Capabilities

  • Instant Memory Reclamation: Frees up gigabytes of RAM in seconds.
  • 🛡️ UAC Admin Mode Detection: Auto-detects token elevation status and displays live badges (Administrator Mode vs User Mode).
  • 📌 System Tray Background Watcher: Auto-optimizes RAM in the background based on customizable memory thresholds (e.g. 85%).
  • 🖼️ Dark Glassmorphism UI: Built with React 18, Vite, and custom SVG gauges.

🔗 Links & Downloads

Developed & Licensed by JOJIN JOHN.

Top comments (0)