Skip to content

Latest commit

 

History

History
658 lines (491 loc) · 25 KB

File metadata and controls

658 lines (491 loc) · 25 KB

MagicX RAM Cleaner - Usage Guide

Full command reference, cleaning level details, usage examples, and background on Windows memory management.

For installation and project overview, see the main README.


Table of Contents


Global Options

These flags can be used with any subcommand:

Flag Description
--no-color Disable coloured terminal output (also respects NO_COLOR env var)
-q, --quiet Suppress banner and non-essential output (implies no verbose)

Commands Reference

clean - Smart Clean

The recommended way to free RAM. Runs multiple operations in optimal order.

magicx-ram-cleaner clean [OPTIONS]

Options:

Flag Description
-l, --level <LEVEL> Cleaning aggressiveness: gentle, moderate, aggressive (default), nuclear
-v, --verbose Show detailed progress of each operation
--report <FILE> Write cleaning results to a JSON report file
--dry-run Preview what operations would run without executing them
--exclude <NAME> Exclude processes by name during working set trimming (case-insensitive, .exe optional, repeatable). Implies per-process trimming instead of kernel-level
Examples:
# Default aggressive clean
magicx-ram-cleaner clean

# Gentle - safe for gaming, only frees what Windows would free first
magicx-ram-cleaner clean --level gentle

# Moderate - good balance
magicx-ram-cleaner clean -l moderate

# Nuclear - maximum RAM recovery, may cause brief slowdown
magicx-ram-cleaner clean -l nuclear -v

# Nuclear clean with JSON report for logging
magicx-ram-cleaner clean -l nuclear --report clean-report.json

# Preview what a nuclear clean would do (no execution)
magicx-ram-cleaner clean -l nuclear --dry-run

# Protect specific processes from working set trimming
magicx-ram-cleaner clean --exclude chrome --exclude firefox

status - Memory Diagnostics

Shows comprehensive memory usage information.

magicx-ram-cleaner status [OPTIONS]

Options:

Flag Description
-d, --detailed Show memory page list breakdown (standby priorities, modified pages, etc.)
-j, --json Output as JSON for scripting/automation
--top <N> Show top N processes ranked by working set (physical RAM) usage

Examples:

# Basic memory overview
magicx-ram-cleaner status

# Detailed view including standby list per-priority breakdown
magicx-ram-cleaner status --detailed

# Top 10 memory-hungry processes
magicx-ram-cleaner status --top 10

# JSON output for scripts
magicx-ram-cleaner status --json

# Detailed JSON - great for monitoring scripts
magicx-ram-cleaner status -d -j

Sample output (detailed):

--- Physical Memory --------------------
  Memory Load:    72%
  Total:          16.00 GB
  Used:           11.52 GB
  Available:      4.48 GB

--- Memory Page Lists ------------------
  Zeroed:         128.00 MB  (32768 pages)
  Free:           0 B  (0 pages)
  Modified:       256.00 MB  (65536 pages)
  Mod-NoWrite:    0 B  (0 pages)

--- Standby List (by priority) ---------
  Total Standby:  3.84 GB  (1006632 pages)
  Priority 0:       512.00 MB   13.0%  ████            Lowest
  Priority 1:       1.28 GB     33.3%  ██████████
  Priority 2:       384.00 MB   10.0%  ███
  Priority 3:       256.00 MB    6.7%  ██
  Priority 4:       512.00 MB   13.3%  ████
  Priority 5:       640.00 MB   16.7%  █████
  Priority 7:       256.00 MB    6.7%  ██              Highest

purge-standby - Standby List Purge

Direct equivalent of EmptyStandbyList, but with options.

magicx-ram-cleaner purge-standby [OPTIONS]

Options:

Flag Description
--low-priority Only purge priority-0 standby pages (safest)
-v, --verbose Show detailed progress

Examples:

# Purge ALL standby pages (like EmptyStandbyList)
magicx-ram-cleaner purge-standby

# Only purge low-priority pages (safer, less impact)
magicx-ram-cleaner purge-standby --low-priority

flush-modified - Modified Page Flush

Forces dirty (modified) pages to be written to disk/pagefile.

magicx-ram-cleaner flush-modified [OPTIONS]

Why you should use this: Modified pages are pages that have been changed in memory but not yet written to disk. They can't be freed until they're saved. Flushing them first means the subsequent standby purge will free more RAM.

Pro tip: Run this before purge-standby for maximum effect:

magicx-ram-cleaner flush-modified
magicx-ram-cleaner purge-standby

(The clean command does this automatically.)


empty-workingsets - Working Set Trim

Forces all processes to release their allocated memory pages.

magicx-ram-cleaner empty-workingsets [OPTIONS]

Options:

Flag Description
--per-process Use per-process trimming instead of kernel-level (slower but more detailed)
--exclude <NAME> Exclude processes by name (case-insensitive, repeatable). Implies --per-process
-v, --verbose Show detailed progress

Examples:

# Kernel-level trim - fastest, hits ALL processes
magicx-ram-cleaner empty-workingsets

# Per-process trim - shows how many processes were trimmed
magicx-ram-cleaner empty-workingsets --per-process -v

# Trim all processes except Chrome and Firefox
magicx-ram-cleaner empty-workingsets --exclude chrome --exclude firefox

Kernel-level vs Per-process:

Aspect Kernel-level (default) Per-process
Speed Single kernel call Iterates all processes
Coverage ALL processes including protected Only processes we can open
Detail No per-process info Reports counts
Reliability Cannot fail per-process Some processes may fail

flush-cache - File System Cache Flush

Releases the file system cache, freeing RAM used for cached file data.

magicx-ram-cleaner flush-cache [OPTIONS]

Unique to MagicX - EmptyStandbyList cannot do this. The file system cache can consume many gigabytes of RAM on systems that do heavy I/O.

Examples:

magicx-ram-cleaner flush-cache
magicx-ram-cleaner flush-cache -v

flush-registry - Registry Cache Flush

Flushes the Windows registry cache, writing dirty hive pages to disk and freeing the RAM they occupy.

magicx-ram-cleaner flush-registry [OPTIONS]

Unique to MagicX - EmptyStandbyList cannot do this. Uses NtSetSystemInformation(SystemRegistryReconciliationInformation) to force all cached registry modifications to disk. Included automatically in aggressive and nuclear cleaning levels.

Examples:

magicx-ram-cleaner flush-registry
magicx-ram-cleaner flush-registry -v

combine - Memory Page Deduplication

Scans physical memory for identical pages and combines them using copy-on-write.

magicx-ram-cleaner combine [OPTIONS]

Windows 10+ only. This can take several seconds on systems with lots of RAM. It's particularly effective when you have many instances of the same application (e.g., multiple browser tabs, VMs).


monitor - Continuous Monitoring

Watch memory usage in real-time with optional auto-cleaning.

magicx-ram-cleaner monitor [OPTIONS]

Options:

Flag Description
-i, --interval <SECONDS> Check interval in seconds (default: 5)
-t, --threshold <PERCENT> Auto-clean when memory load exceeds this %
-l, --level <LEVEL> Cleaning level for auto-clean (default: aggressive)
-c, --cooldown <SECONDS> Cooldown after auto-clean before cleaning again (default: 2x interval)
-v, --verbose Show details during auto-clean

Examples:

# Just monitor, no auto-clean
magicx-ram-cleaner monitor

# Monitor every 10 seconds
magicx-ram-cleaner monitor --interval 10

# Auto-clean at 80% usage with aggressive cleaning
magicx-ram-cleaner monitor --threshold 80

# Auto-clean with 30-second cooldown between cleans
magicx-ram-cleaner monitor -t 85 --cooldown 30

# Auto-clean at 90% with gentle cleaning, check every 3 seconds
magicx-ram-cleaner monitor -i 3 -t 90 -l gentle

# Detailed monitoring with nuclear auto-clean at 85%
magicx-ram-cleaner monitor -t 85 -l nuclear -v

context-menu - Right-Click Context Menu

Install or uninstall a cascading "MagicX RAM Cleaner" submenu in the Windows right-click context menu (Desktop background and folder windows).

magicx-ram-cleaner context-menu <install|uninstall>

Subcommands:

Subcommand Description
install Add context menu entries (creates registry keys under HKCR)
uninstall Remove context menu entries (deletes registry keys)

Context menu entries installed:

Entry Action Icon
Quick Clean clean --level gentle --notify Phosphor LEAF glyph
Standard Clean clean --level moderate --notify Phosphor LIGHTNING glyph
Deep Clean clean --level aggressive --notify Phosphor FIRE glyph
Purge Standby List purge-standby --notify Phosphor BROOM glyph
Memory Status status --notify Phosphor GAUGE glyph

Nuclear is intentionally excluded from the context menu because it is too destructive for one-click access.

All entries use --notify mode: no terminal window appears, the operation runs silently, and a brief Windows balloon notification shows the result. The notification auto-dismisses after ~2 seconds and is not saved in the Action Center.

Examples:

# Install context menu entries (run as Administrator)
magicx-ram-cleaner context-menu install

# Uninstall context menu entries
magicx-ram-cleaner context-menu uninstall

After installing, right-click your Desktop or any folder background to see the "MagicX RAM Cleaner" submenu.


Cleaning Levels Explained

Level Operations Impact Best For
gentle Purge ALL standby pages Low - clears disk cache, no process impact Gaming, production servers
moderate Flush modified pages, then purge ALL standby Low-Medium - brief I/O spike from flushing Daily maintenance
aggressive File cache + registry flush + empty working sets + flush modified + purge ALL standby Medium - brief I/O spike as apps re-fault Most users (default)
nuclear Everything above + memory combining + second pass Highest - may cause temporary slowdown Before running demanding apps, troubleshooting

Gentle

1. Purge ALL standby pages (priorities 0-7)

Clears the entire standby list. These are cached copies of disk data that are already outside every process's working set. No running process is affected; the only cost is that files may need to be re-read from disk on next access. Safe to run at any time.

Moderate

1. Flush modified page list to disk
2. Purge ALL standby pages

First writes all dirty (modified) pages to disk, converting them to standby, then purges the entire standby list. Reclaims more memory than Gentle because it also drains the modified page list. No process working sets are touched.

Aggressive (Default)

1. Flush file system cache
2. Flush registry cache
3. Empty all process working sets (kernel-level)
4. Flush modified page list to disk
5. Purge ALL standby pages

The full sequence. Flushes the file cache and registry cache first (can reclaim GBs on I/O-heavy systems), trims all processes, writes dirty pages to disk, then purges the entire standby list.

Nuclear

1. Flush file system cache
2. Flush registry cache
3. Empty all process working sets (kernel-level)
4. Flush modified page list to disk
5. Purge ALL standby pages
6. Memory page combining (dedup)
7. Second-pass: Flush modified list again
8. Second-pass: Purge standby list again

Everything plus memory deduplication. The second pass catches pages that were modified during the combining step. Use this when you need maximum free RAM.


Usage Examples

For Normal Users

"I just want more free RAM":

magicx-ram-cleaner clean

"My PC feels slow":

# Check memory status first
magicx-ram-cleaner status

# If memory load is high (>80%), clean it
magicx-ram-cleaner clean

"I want to clean RAM before launching a game":

magicx-ram-cleaner clean --level gentle

For Gamers

Before launching a game - free RAM without hurting game cache:

magicx-ram-cleaner clean -l gentle

After closing a game - reclaim all memory:

magicx-ram-cleaner clean -l aggressive

Auto-clean while gaming - keep RAM free automatically:

# Clean when RAM usage hits 85%, check every 10 seconds, gentle level
magicx-ram-cleaner monitor -i 10 -t 85 -l gentle

For Power Users / Sysadmins

Maximum single clean with verbose output:

magicx-ram-cleaner clean -l nuclear -v

Manual step-by-step cleaning (full control):

# Step 1: See what we're working with
magicx-ram-cleaner status --detailed

# Step 2: Flush the file system cache
magicx-ram-cleaner flush-cache

# Step 3: Trim process working sets
magicx-ram-cleaner empty-workingsets

# Step 4: Flush modified pages to disk
magicx-ram-cleaner flush-modified

# Step 5: Purge the standby list
magicx-ram-cleaner purge-standby

# Step 6: Check results
magicx-ram-cleaner status --detailed

Monitor a server and auto-clean at 90%:

magicx-ram-cleaner monitor -i 30 -t 90 -l moderate

Get memory stats as JSON for your monitoring script:

$memory = magicx-ram-cleaner status --json --detailed | ConvertFrom-Json
if ($memory.snapshot.memory_load_percent -gt 85) {
    Write-Host "WARNING: High memory usage!"
}

For Automation / Scripts

Scheduled Task - clean every hour:

# Create a scheduled task (run in elevated PowerShell)
$action = New-ScheduledTaskAction -Execute "C:\Tools\magicx-ram-cleaner.exe" -Argument "clean -l moderate"
$trigger = New-ScheduledTaskTrigger -RepetitionInterval (New-TimeSpan -Hours 1) -At "00:00" -Once
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest
Register-ScheduledTask -TaskName "MagicX RAM Clean" -Action $action -Trigger $trigger -Principal $principal

Batch file - clean and log:

@echo off
echo [%date% %time%] Starting RAM clean >> C:\Logs\ramclean.log
C:\Tools\magicx-ram-cleaner.exe clean -l aggressive >> C:\Logs\ramclean.log 2>&1
echo [%date% %time%] Clean complete >> C:\Logs\ramclean.log

PowerShell - conditional cleaning:

$status = magicx-ram-cleaner status --json | ConvertFrom-Json
if ($status.snapshot.memory_load_percent -gt 80) {
    magicx-ram-cleaner clean -l aggressive
    Write-Host "RAM cleaned! Load was $($status.snapshot.memory_load_percent)%"
}

How Windows Memory Works

Understanding Windows memory management helps you use MagicX effectively.

Memory Page Lists

Windows organizes physical memory pages into several lists:

+--------------------------------------------------+
|                Physical RAM                       |
+----------+-----------+-----------+---------------+
| Active   | Modified  | Standby   | Free/Zeroed   |
| (In Use) | (Dirty)   | (Cached)  | (Available)   |
+----------+-----------+-----------+---------------+
| Pages    | Pages     | Pages     | Pages ready   |
| actively | changed   | cached    | for immediate |
| used by  | but not   | but not   | allocation.   |
| running  | written   | actively  |               |
| programs | to disk   | used.     |               |
|          | yet.      | Can be    |               |
|          |           | reclaimed.|               |
+----------+-----------+-----------+---------------+
  • Active (In Use): Pages actively being used by running programs. Can't be freed without terminating the program.
  • Modified (Dirty): Pages that have been changed in memory but not yet saved to disk. Must be written to disk before they can be freed.
  • Standby (Cached): Pages from recently-used files or programs. Still contain valid data that could be re-used (avoiding a disk read), but can be repurposed immediately if needed.
  • Free/Zeroed: Empty pages ready for allocation.

Standby Priority Levels (0-7)

Windows assigns priority levels to standby pages:

  • Priority 0 (Lowest): Least important, freed first when memory pressure occurs.
  • Priority 7 (Highest): Most important, freed last.

MagicX's --low-priority flag only frees priority 0 pages, preserving the more important cached data.

What "Available" Memory Really Means

Windows Task Manager shows "Available" memory as: Free + Zeroed + Standby. This is because standby pages CAN be repurposed instantly. But they also contain cached data that speeds up your system.

MagicX moves pages from Standby (cached) to Free, increasing truly-free RAM at the cost of losing cached data (which will be re-read from disk when needed).

The Optimal Cleaning Sequence

MagicX's aggressive/nuclear levels follow this sequence for a reason:

  1. Flush file cache - Releases cached file data, immediately freeing RAM
  2. Flush registry cache - Writes dirty registry hive pages to disk
  3. Empty working sets - Forces processes to give back unused pages (these move to Modified/Standby)
  4. Flush modified - Writes dirty pages to disk (Modified -> Standby)
  5. Purge standby - Frees all cached pages (Standby -> Free)

If you skip step 4, modified pages can't be freed by step 5. This is why MagicX cleans more effectively than just running EmptyStandbyList standbylist.


Comparison with Other Tools

Feature MagicX EmptyStandbyList RAMMap Mem Reduct
Standby purge Yes Yes Yes Yes
Low-priority only Yes Yes No No
Working set trim Yes Yes Yes Yes
Modified flush Yes Yes No No
File cache flush Yes No No No
Registry cache flush Yes No No No
Memory combining Yes No No No
Smart levels Yes No No No
Before/after stats Yes No No Partial
Memory list details Yes No Yes No
Auto-monitoring Yes No No Yes
JSON output Yes No No No
CLI support Yes Yes No No
GUI with dashboard Yes No Yes Yes
Portable (no install) Yes Yes Yes No
Open source Yes No No Yes

FAQ

Do I need to run as Administrator?

Yes. Memory management requires elevated privileges. Right-click your terminal (PowerShell/CMD) and select "Run as administrator", or right-click the .exe and choose "Run as administrator".

The binary includes a UAC manifest that will prompt for elevation automatically when double-clicked.

Will this break anything?

No. MagicX only uses official Windows APIs to manage memory. It does what Windows would do naturally under memory pressure, just on-demand instead of waiting.

After cleaning:

  • Programs may feel slightly slower for a moment as they re-read cached data from disk
  • No data is lost. Modified pages are saved to disk before being freed
  • All programs continue running normally

How often should I clean?

  • Normal use: When you notice high memory usage or slowdowns
  • Gaming: Before launching games (gentle level)
  • Servers: Use the monitor with auto-clean at 85-90%
  • General maintenance: The aggressive level every few hours is fine

What's the difference between this and just restarting?

A restart clears ALL memory but also closes all your programs. MagicX frees RAM while keeping everything running.

Does this work on Windows ARM?

Currently built for x86-64 only. ARM support may be added in the future.

Can I use this without the command line?

Yes. MagicX includes a built-in GUI. Double-click the exe (or run it without arguments) to launch the graphical interface with:

  • Real-time memory dashboard with usage bars and history chart
  • One-click cleaning at all 4 levels (Gentle / Moderate / Aggressive / Nuclear)
  • Continuous monitoring with automatic cleaning at configurable thresholds
  • Process list sorted by memory usage
  • Settings panel for dark mode, tray icon, and context menu integration

You can also install Desktop context menu integration:

magicx-ram-cleaner context-menu install

This adds a "MagicX RAM Cleaner" submenu to your Desktop and folder right-click menus.