11

I have 4 GB of RAM, but Windows still thrashes disk sometimes (especially often when an application is minimized for some time and then I activate it again). Completely stupid, because Task Manager shows 2 GB of RAM are free. Is there any way to prevent Windows swapping out program memory?

I tried setting Superfetch to cache startup files only (it helped a bit) and turning off paging file (it helped much, and worked well for me in Windows XP; but Windows Vista/Windows 7 don't allow that - it shows "low on memory" message frequently, even when I have 1 GB of RAM free.)

What can you advise me to do?

skevar7
  • 1,035

6 Answers6

7

Mark Russianovich has written a good long article on Virtual Memory,
Pushing the Limits of Windows: Virtual Memory

Virtual memory separates a program’s view of memory from the system’s physical memory, so an operating system decides when and if to store the program’s code and data in physical memory and when to store it in a file. The major advantage of virtual memory is that it allows more processes to execute concurrently than might otherwise fit in physical memory.

While virtual memory has limits that are related to physical memory limits, virtual memory has limits that derive from different sources and that are different depending on the consumer. For example, there are virtual memory limits that apply to individual processes that run applications, the operating system, and for the system as a whole. It's important to remember as you read this that virtual memory, as the name implies, has no direct connection with physical memory. Windows assigning the file cache a certain amount of virtual memory does not dictate how much file data it actually caches in physical memory; it can be any amount from none to more than the amount that's addressable via virtual memory.

It is a very good read.

How Big Should I Make the Paging File?
Perhaps one of the most commonly asked questions related to virtual memory is, how big should I make the paging file? There’s no end of ridiculous advice out on the web and in the newsstand magazines that cover Windows, and even Microsoft has published misleading recommendations. Almost all the suggestions are based on multiplying RAM size by some factor, with common values being 1.2, 1.5 and 2. Now that you understand the role that the paging file plays in defining a system’s commit limit and how processes contribute to the commit charge, you’re well positioned to see how useless such formulas truly are.


Earlier article: Pushing the Limits of Windows: Physical Memory

You can see physical memory layout with the Meminfo tool by Alex Ionescu.

nik
  • 57,042
4

Just leave the virtual memory management to Windows, it does a good job. Paging (and thus Mark Russinovic's blurbs regarding the matter) are rather irrelevant to disk thrashing (if you have system memory in abundance), you are looking for NTFS tweaks.

O'Reilly has an interesting article about NTFS Performance Hacks.

On the hardware side: a better hard drive with higher spin rate and larger cache will help a great deal too.

And here is how to kill the low memory warning, take ownership and nuke the following registry keys.

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WDI\DiagnosticModules\ {5EE64AFB-398D-4edb-AF71-3B830219ABF7}]

and

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WDI\DiagnosticModules\ {45DE1EA9-10BC-4f96-9B21-4B6B83DBF476}]

This will prevent the Diagnostics Service from loading RADAR. It works for me in Windows Vista, the keys are present in Windows 7. I haven't tried it though - just backup those keys before you delete them.

2

The only way I've found was to increase RAM size to 8 GBs and turn off paging by setting

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Memory Management\DisablePagingExecutive=1

(reboot required).

That reduced disk activity to nearly zero.

studiohack
  • 13,477
skevar7
  • 1,035
1

Check out Control Panel\System and Security\System > Advanced System Settings > [Advanced] > Performance: Settings > [Advanced]

Processor scheduling is related to your issue, as is the ability to disable the paging file which you shouldn't be doing. (You need it)

0

It sounds like you installed a cache/mem cleaner. They move applications to swap when you minimize them rather than leaving them in memory.

Is the system slow or are you just using the word thrash because you see the HD light flashing?

0

Move to the Linux, it doesn't do that.

People would be telling you that Windows is smarter than you and you shouldn't fiddle with page file settings and they are right. But that system is mostly tuned to allocate new memory for a process almost instantly and it does that good. One of the side effect is that it moves everything you have in memory into disk all the time, so when it needs new portion of memory it could just erase this portion of memory and give it right away if it hasn't changed of course. I believe that when you leave you applications running, all of they data got stored into disk and then at some point other applications or caching system start using this memory. So application is left with bare minimum of their data into physical RAM and when you start using it again it has to get everything back from the disk.

That said, I don't think you can do everything with that, it just one of the main properties of the system. You can make it only worse by turning the page off or doing any other system tuning. You can't make it work as you like as it just wasn't written with that in mind.

vava
  • 5,948