Sub topic 10
Low memory warnings and virtual memory
This chapter assumes you can open Task Manager and Control Panel, and that you know what RAM and a hard drive or SSD do. It also assumes you know the CompTIA troubleshooting steps from the first chapter. Here you will learn what Windows does when physical memory runs short, how to read the signs, and which fix to pick.
How Windows uses memory
Programs need memory to hold their code and data. Windows gives each program a private range of addresses called virtual memory. Windows maps those addresses to one of two places:
- Physical RAM, which is fast.
- The page file, a hidden file on disk (usually
C:\pagefile.sys) that holds data pushed out of RAM. Disk is far slower than RAM.
The terms below appear in Task Manager, Resource Monitor, and exam questions.
| Term | Meaning |
|---|---|
| Working set | The part of a process's memory currently in RAM |
| Commit charge | Total virtual memory promised to processes, in RAM and page file combined |
| Commit limit | RAM plus page file size. Windows cannot commit more than this |
| Paging | Moving blocks of memory between RAM and the page file |
| Hard fault | A program needs data that is only in the page file, so Windows reads it from disk |
| Memory leak | A program keeps requesting memory and never releases it |
When RAM fills up, Windows pushes the least-used data to the page file to make room. A little paging is normal. Constant paging is called thrashing, and it makes the whole system crawl because the disk cannot keep up.
Recognizing the symptoms
Typical signs of memory pressure are:
- A pop-up reading "Your computer is low on memory" or "Windows successfully diagnosed a virtual memory problem."
- A message that Windows is closing programs to prevent information loss.
- Slow switching between windows, with the disk activity light constantly on.
- Applications that fail with out-of-memory errors or close unexpectedly.
- High memory use in Task Manager that does not fall after you close programs.
Windows logs a Resource-Exhaustion-Detector event (Event ID 2004) in the System log when it warns about low virtual memory. This ties back to the Event Viewer chapter. The event lists the processes using the most memory, which often names the culprit directly.
Gathering evidence
Start in Task Manager. The Performance tab shows memory in use, available memory, committed (used/limit), and cached. Sort the Processes tab by Memory to find large consumers. A process whose number rises steadily while you do nothing is a leak candidate.
Resource Monitor (resmon) has a Memory tab that is more detailed. Watch the Hard Faults/sec column and the graph for committed memory. A high commit percentage with many hard faults means the system is short of RAM.
You can also collect numbers from PowerShell. This script reports physical and virtual memory in megabytes and then shows page file usage.
$os = Get-CimInstance Win32_OperatingSystem
[pscustomobject]@{
TotalRAM_MB = [math]::Round($os.TotalVisibleMemorySize / 1KB)
FreeRAM_MB = [math]::Round($os.FreePhysicalMemory / 1KB)
CommitLimit_MB = [math]::Round($os.TotalVirtualMemorySize / 1KB)
CommitFree_MB = [math]::Round($os.FreeVirtualMemory / 1KB)
}
Get-CimInstance Win32_PageFileUsage |
Select-Object Name, AllocatedBaseSize, CurrentUsage, PeakUsageThe size properties on Win32_OperatingSystem are in kilobytes, so the script divides by 1 KB to get megabytes. The page file properties are already in megabytes. If PeakUsage is close to AllocatedBaseSize, the page file is too small for your workload.
For a live view of paging, sample these performance counters:
Get-Counter '\Memory\Available MBytes', '\Memory\Pages/sec', '\Paging File(_Total)\% Usage' -SampleInterval 2 -MaxSamples 5Low Available MBytes together with sustained high Pages/sec confirms heavy paging.
Choosing a fix
Pick the least destructive fix that matches the evidence.
- Close or restart the program. This releases its memory at no cost. Restarting the computer clears leaked memory from every process.
- Update or repair the faulty program. Leaks are usually software bugs, and a vendor update may fix them.
- Reduce startup load. Disable unneeded startup programs so less memory is taken at boot (see the services and startup chapter).
- Check the page file. Open System Properties, then Advanced, then Performance Settings, then Advanced, then Virtual memory Change. Leave "Automatically manage paging file size for all drives" selected unless you have a reason not to. If a custom size is set too small, switch back to automatic or enlarge it. Changes to the page file require a restart.
- Add RAM. If the system is always short of memory under normal use, only more RAM solves it. Paging cannot make up for too little RAM.
- Use a 64-bit edition where possible. A 32-bit Windows can use at most about 4 GB of RAM, so extra installed memory goes unused.
Memory warnings versus faulty RAM
Low memory warnings mean there is not enough memory for the workload. They do not mean the RAM is broken. Faulty RAM usually shows up as random stop errors, spontaneous restarts, or corrupted data. Run the Windows Memory Diagnostic (mdsched.exe) if you suspect failing modules. It restarts the computer and tests memory before Windows loads. Also consider malware if an unknown process uses a large amount of memory, a topic covered in a later chapter.
Exam tips
- "Low on memory" plus one growing process points to a memory leak. The first-line answer is to close or restart the program, then update it.
- "Low on memory" plus a tiny or disabled page file points to a virtual memory setting. Restore the automatic setting.
- Constant disk activity and slow response with RAM nearly full points to excessive paging. The long-term fix is more RAM.
- Random BSODs with normal memory use point to bad RAM or drivers, not to the page file.
Exercise
A user reports the message "Your computer is low on memory" several times a day. Task Manager shows one browser helper process whose memory climbs from 300 MB to 4 GB over a few hours. The page file is set to system managed. What is the most likely cause, and what should you do first?
Show answer
The most likely cause is a memory leak in the browser or its extension. First close or restart the program, which releases the memory, then update the browser and disable or remove suspect extensions. Enlarging the page file only delays the warnings and does not fix the leak.
Exercise
A technician finds that Resource Monitor shows 95 percent of the commit limit in use, high Hard Faults/sec, and constant disk activity. The workstation has 4 GB of RAM and runs many large applications at once. Which fix addresses the root cause?
Show answer
Add more RAM. The system is paging heavily because physical memory is too small for the workload. Moving the page file or enlarging it may help slightly, but it cannot match the speed of RAM.