Sub topic 10
Low memory warnings and virtual memory
This chapter assumes you can open Task Manager, Control Panel and an elevated command prompt. It also assumes you know the difference between RAM (fast, temporary memory) and storage (slow, permanent). The goal is to recognize a low memory warning and pick the right fix.
How Windows uses memory
Programs run in RAM. When RAM fills up, Windows moves pages of data that are not in active use to the page file (pagefile.sys) on disk. This extra space is called virtual memory. Disk is far slower than RAM, so heavy paging makes the whole system feel slow.
Windows also keeps a commit limit. This is RAM plus the page file size. If programs ask for more memory than the commit limit allows, Windows shows the "Your computer is low on memory" warning and may close programs.
Recognizing the symptoms
- A "Your computer is low on memory" or "Out of memory" message.
- Programs closing or refusing to open.
- Constant disk activity and a sluggish interface, even with a low CPU load.
- Memory use near 100% in Task Manager.
Finding the cause
- Open Task Manager and select the Performance tab, then Memory. Check In use, Committed and Available.
- Open the Processes tab and sort by Memory to find the heaviest program.
- Open Resource Monitor (
resmon) and use the Memory tab. A high Hard Faults/sec value confirms heavy paging. - If one process keeps growing and never shrinks, it may have a memory leak. That is a program bug that fails to release memory it no longer needs.
Fixing the problem
Choose the least destructive fix first.
- Close programs you do not need and restart any program with a leak.
- Reboot. This clears leaked memory.
- Remove unneeded startup programs.
- Check the page file. Open System Properties, then Advanced, then Performance Settings, then Advanced, then Virtual memory. Set it to System managed size unless you have a reason to do otherwise. A disabled or very small page file causes out of memory errors even when RAM looks free.
- Make sure the drive holding the page file has free space.
- Add RAM if normal workloads exceed what is installed.
You can check the current page file settings from PowerShell:
Get-CimInstance Win32_PageFileUsage | Select-Object Name, AllocatedBaseSize, CurrentUsage, PeakUsageAllocatedBaseSize and CurrentUsage are in megabytes. A PeakUsage close to the allocated size suggests the file is too small.
Common errors
- Turning off the page file to "speed things up". This causes out of memory errors and can stop crash dumps from being written.
- Blaming RAM when a single leaking program is the cause.
- Setting a tiny fixed page file size that is too small for the workload.
- Ignoring malware, which can consume memory in the background.
Exercise
A user reports "Your computer is low on memory" warnings. Task Manager shows memory at 95% and Resource Monitor shows high Hard Faults/sec. The user normally runs many large programs at once, and no single process stands out. What is the best long-term fix?
Show answer
Add more RAM. High hard faults mean Windows is paging heavily, and no single process is the cause, so the normal workload exceeds the installed memory. Setting the page file to system managed is a reasonable first step, but it does not remove the shortage.
Exercise
One program's memory use grows every hour and never drops until you restart it. What is this called, and what do you do first?
Show answer
This is a memory leak. Restart the program to free the memory, then check for an update or reinstall it, since the fix is in the program's code.