Yes, you can clean virtual memory on a PC, and it’s often as simple as restarting the system or running a built-in Windows tool to clear the pagefile. Virtual memory (also called the pagefile) acts as temporary storage for RAM that’s not being used immediately, but it can bloat over time with unused files. Most PCs handle this automatically, but manually clearing it frees up disk space and sometimes improves speed—especially if your system is struggling with slow response or high CPU usage.
What You’ll Need
- A Windows PC running Windows 7 or later (XP and earlier lack modern tools).
- Administrator privileges (some steps require them).
- At least 1GB of free space on your primary drive (C:). If your disk is nearly full, clean it first with
Disk Cleanup. - Basic familiarity with Task Manager (Ctrl+Shift+Esc).
Step-by-Step
- Check virtual memory usage first.
- Press Win + R, type
sysdm.cpl, and hit Enter. This opens System Properties. - Select the Advanced tab, then click Settings under Performance. In the new window, choose the Advanced tab again.
- Under Virtual memory, click Change. Note the Currently allocated size and Minimum size. If your disk has 10GB+ free, you can adjust these later (but only if you’re low on RAM; Windows manages this well by default).
- Press Win + R, type
- Clear the pagefile manually (fastest method).
- Open Command Prompt as Administrator:
- Right-click the Start menu, select Windows Terminal (Admin) or Command Prompt (Admin).
- If prompted, confirm the UAC prompt.
- Type or paste the following and press Enter:
cleanmgr /sagerun:1
This opens Disk Cleanup with a pre-selected option to clear temporary files (including virtual memory artifacts). - In Disk Cleanup, check:
- Temporary files (deletes browser cache, downloads, etc.).
- System error memory dump files (older Windows memory dumps).
- Recycle Bin (if you want to clear it).
- Click OK to confirm. Wait for the process to finish.
- Open Command Prompt as Administrator:
- Use Task Manager to force-close memory-hogging apps.
- Press Ctrl + Shift + Esc to open Task Manager (faster than right-clicking the taskbar).
- Go to the Processes tab, sort by Memory (click the column header), and identify processes using 50MB+ of RAM.
- Right-click each suspect process and select End task. This frees RAM immediately. Avoid ending system processes (e.g., System, svchost.exe).
- Restart your PC to clear virtual memory fully.
- Close all programs and save work.
- Click the Start menu, then Power > Restart. This flushes the pagefile and resets RAM allocation.
- Adjust virtual memory settings (optional, for advanced users).
- Return to System Properties (from Step 1) and click Change under Virtual memory.
- Uncheck Automatically manage paging file size.
- Select Custom size, then:
- Set Initial size to 1.5x your installed RAM (e.g., 3GB for 2GB RAM).
- Set Maximum size to 3x your RAM (e.g., 6GB).
- Click Set, then OK. Reboot when prompted.
- Warning: Only do this if your system has <16GB RAM or runs memory-intensive apps (e.g., video editing). Over-optimizing can slow down Windows.
If that did not work:
- Run Windows Maintenance:
- Open Settings > System > Storage > Storage sense.
- Toggle Storage sense on, then click Clean now under Temporary files.
- Check System files and Recycle Bin to clear more space.
- Check for malware: Run Windows Defender (Settings > Update & Security > Windows Security > Virus & threat protection) and scan your system. Malware can corrupt virtual memory.
- Upgrade your RAM if your PC consistently uses <80% of virtual memory. Virtual memory is a crutch, not a replacement for physical RAM.
Common Mistakes
- Deleting the pagefile manually.
Some guides suggest deleting
pagefile.sys, but this breaks Windows. The pagefile is required for hibernation and RAM overflow. If you’re low on disk space, resize it (as in Step 5) instead. - Ending critical processes in Task Manager. Never terminate System, svchost.exe, or Windows Explorer. These handle core functions. Sort by Memory to target only non-essential apps.
- Adjusting virtual memory without freeing disk space first. If your C: drive is <5% free, resizing the pagefile may cause crashes. Free up space with Disk Cleanup or move the pagefile to another drive (Settings > Advanced system settings > Performance > Settings > Advanced > Virtual memory > Change > select a different drive).
- Ignoring background processes. Apps like Google Chrome or Spotify often leak memory. Close them completely (right-click taskbar icon > Quit) rather than just minimizing.
Tips
- Use Ctrl + Shift + Esc to open Task Manager quickly—no need to hunt through the Start menu.
- For frequent cleanups, add
cleanmgr /sagerun:1to a shortcut and pin it to your taskbar. - Monitor virtual memory in real time with Resource Monitor:
- Open Task Manager, then click Performance > Open Resource Monitor.
- Go to the Memory tab to see active pagefile usage.
- If your PC has an SSD, disable hibernation (
powercfg /h offin Command Prompt) to save space, as hibernation creates a largehiberfil.sysfile. - For gamers: Set the pagefile to a fixed size (e.g., 4GB) to prevent sudden slowdowns during games.
Troubleshooting
My PC crashes after adjusting virtual memory settings.
Undo the changes immediately:
- Return to System Properties > Virtual memory > Change.
- Re-enable Automatically manage paging file size and click Set.
- Reboot.
The pagefile won’t clear, and my disk is full.
- Free up space with Disk Cleanup (as in Step 2).
- Move the pagefile to another drive (e.g., D:):
- In Virtual memory settings, click Change.
- Select the drive with free space, then click OK.
- Windows will create a new pagefile there.
- If the drive is also full, delete unnecessary files (e.g., old downloads, duplicate photos) or upgrade your storage.
Task Manager says virtual memory is at 100%, but my PC is fast.
This is normal if your physical RAM is sufficient. Virtual memory only kicks in when RAM is fully used. If your PC feels slow despite high virtual memory usage, check for:
- Too many background apps (use Task Manager to close them).
- Malware (run a full scan with Windows Defender).
- Hard drive issues (run
chkdsk /fin Command Prompt as Admin).
I didn’t see the “Virtual memory” option in System Properties.
This happens on some SSDs or if the pagefile is disabled. To re-enable it:
- Open Command Prompt as Admin and run:
systempropertiesperformance
- Click Advanced > Settings > Advanced > Virtual memory > Change.
- Ensure Automatically manage paging file size is checked, then click OK.
My PC runs slower after cleaning virtual memory.
This usually means your RAM is insufficient. Check your installed RAM:
- Press Win + R, type
msinfo32, and hit Enter. - Look under System Summary > Components > Memory.
Frequently Asked Questions
How often should I clean virtual memory?
Windows handles virtual memory automatically, so you don’t need to clean it regularly. Only do it if your PC is slow, the disk is nearly full, or you notice the pagefile growing uncontrollably. A monthly check with Disk Cleanup is enough for most users.
Does cleaning virtual memory delete my saved games or documents?
No. Virtual memory stores temporary data, not your files or game saves. However, ensure you’ve saved work before rebooting, as any unsaved data in RAM will be lost.
Can I use third-party tools to clean virtual memory?
Avoid tools like CCleaner or Auslogics for virtual memory cleanup. They often delete unnecessary system files or crash Windows. Stick to built-in tools like Disk Cleanup or Task Manager.
Why does my virtual memory usage spike when I open Task Manager?
Task Manager itself uses minimal memory, but opening it can trigger Windows to pre-load related system files. The spike is temporary and normal. If usage stays high, check for memory leaks in apps (e.g., Chrome with too many tabs).
Is it safe to disable virtual memory entirely?
No. Virtual memory is a safety net for RAM. Disabling it (Automatically manage paging file size unchecked + Custom size set to No paging file) will cause crashes when your RAM is full. Only disable it if you’re running on an SSD with plenty of free space and have enough RAM (8GB+ for modern apps).
How do I check if virtual memory is working?
Use Resource Monitor (Task Manager > Performance > Open Resource Monitor > Memory tab) to monitor:
- Pagefile: Shows current usage (aim for <80% of max size).
- Commit Charge: Total RAM + virtual memory in use (high values indicate memory pressure).
- Page Faults/sec: Low numbers (<100) mean virtual memory is working smoothly.