Skip to content

Repository files navigation

windows-memory-tools

Three things you can do about Windows memory pressure. One of them helps, and this README tells you which.

License: MIT Platform PowerShell

Search for a Windows RAM cleaner and you get a hundred tools that make a number go up and your machine go slower. The techniques are real — these scripts use the same Windows internals the paid ones do — but almost nobody explains what they cost.

So: what each one actually does, and when it is worth doing.

Start here, it changes nothing

powershell -ExecutionPolicy Bypass -File .\Clear-Memory.ps1 -Report
BEFORE : 4.21 GB free of 15.85 GB (73.4% used)

Application      MB Processes
-----------      -- ---------
chrome         3184        27
Code            921         9
...

Most "I need a RAM cleaner" moments turn out to be one application, and the answer is to close that application rather than to run anything.

What each technique costs

1. Disabling startup applications — this is the one that helps

An application that never starts uses no memory, no CPU and no disk. There is no trade-off, and the effect lasts.

powershell -ExecutionPolicy Bypass -File .\Disable-StartupApps.ps1 -List     # see what is there
powershell -ExecutionPolicy Bypass -File .\Disable-StartupApps.ps1 -WhatIf   # see what would change
powershell -ExecutionPolicy Bypass -File .\Disable-StartupApps.ps1

Nothing is deleted: the HKCU Run key is exported to a .reg file before every change, and -Restore puts it back. Only the per-user Run key is touched — services, scheduled tasks and the machine-wide key are left alone, because those are likelier to matter and harder to undo.

2. Working set trimming — the number lies

EmptyWorkingSet pushes a process's pages out to the pagefile. Free RAM goes up immediately. Then the process touches those pages again and they come back from disk, which is slower than leaving them alone would have been.

It is genuinely useful in one situation: a process has finished a memory-heavy job and is now idle, holding a working set it will not touch again. Trimming that is free. Trimming everything, which is what every RAM cleaner does and what this script does by default, mostly moves the cost somewhere you will not connect to having run it.

3. Purging the standby list — you are deleting a cache

The standby list is not wasted memory. It is file cache: pages Windows kept because reading them again from RAM beats reading them from disk. Windows already gives it up instantly when an application asks for memory.

Purging it makes "free memory" jump, and the next few minutes of work slower while the cache refills from disk.

The one real use: before launching something that needs a large contiguous allocation, or after a huge file operation has filled the standby list with data you will not touch again. That is a narrow case, and it is not "my machine feels slow".

# Both 2 and 3. Run elevated for the standby list purge.
powershell -ExecutionPolicy Bypass -File .\Clear-Memory.ps1

And: closing background applications

powershell -ExecutionPolicy Bypass -File .\Clear-Memory.ps1 -CloseApps -WhatIf

Force-closes what you list in apps.json. This loses unsaved work — it is Stop-Process -Force, not a polite request — so it supports -WhatIf and prompts before each application. Never put an editor, a browser you keep tabs in, or anything you type into on that list.

Configure it

cp apps.example.json apps.json

apps.json is gitignored, because the list is specific to your machine:

{
  "close":   ["steam", "steamwebhelper", "Spotify", "Discord"],
  "protect": ["Code", "explorer", "dwm", "pwsh", "powershell"],
  "startup": ["Steam", "EpicGamesLauncher", "Discord"]
}
  • close — process names for -CloseApps. Process names, no .exe.
  • protect — never closed even if listed in close. A backstop, not a substitute for keeping the list sensible.
  • startupregistry value names in the Run key, which are often not the application's name. Run Disable-StartupApps.ps1 -List to get the real ones.

What actually helps, in order

  1. Close the application at the top of -Report. Usually a browser.
  2. Disable startup applications you launch manually anyway.
  3. Buy more RAM. Unsatisfying, and still the correct answer for most people running out of it every day.
  4. Everything else in this repository.

If Windows is paging heavily with nothing obviously large running, the problem is a leak or a genuine shortage, and neither is fixed by moving pages around.

Requirements

Windows 10/11, PowerShell 5.1 (built in). The standby list purge needs an elevated shell; everything else does not.

Early days

These started as scripts on my own machine and the honest framing above is most of the value. Feedback and bug reports are welcome — I am still working on this. Especially:

  • Measurements that contradict what this README claims. If trimming demonstrably helped on your workload, I would like the numbers, and the README should say so.
  • A NtSetSystemInformation return code you hit that is not handled.
  • Startup entries in places this does not look at, where moving the check would be safe.

Open an issue for any of it.

Licence

MIT — see LICENSE. These scripts trim working sets, purge kernel memory lists and force-close processes. Read them before running them.


🇹🇷 Türkçe: README.tr.md

About

Windows memory scripts that tell you what each technique costs, not just what it frees. Startup control, working set trim, standby list purge

Topics

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages