How to reduce disk thrashing (paging)?

11

4

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

Posted 2009-08-31T11:57:12.270

Reputation: 925

1The term thrashing generally refers to the situation where physical memory is full or nearly full, and constant page swaps occur. It does not refer to normal page swap activity. What you are seeing is not thrashing, but just how the memory management algorithm was designed. Keep space available for newly spawned processes, assume that a process that has its window minimized is not being used and should move its memory off to disk and the such. – spowers – 2010-03-14T14:48:09.403

6You don't want to turn superfetch off with 4GB of RAM, but you might want to turn Indexing off. Leave the page file alone, Windows knows more about it than any of us. I can't help with the paging, though. – Phoshi – 2009-08-31T12:03:38.887

2No, I certainly DO want to turn it off. Damned thing is too badly designed. Once I found it loading all files of some game at each boot (I used to play in the evenings), and that ate half of my RAM, and that was last day Superfetch was running on my PC with unrestricted settings. – skevar7 – 2009-08-31T14:31:55.163

2That's the worst decision ever to assume that because a window is minimized it is not being used. If it's minimized, it's because there's not enough room for it on the screen while multitasking. I'm so sick of returning to my computer and despite having few programs running, it will lag and stutter to bring data back from the page file when I'm restoring some windows from a minimized state, despite have GIGs of free RAM. The page file should NEVER be touched unless I'm running out of RAM. If Windows wants to make assumptions about minimized programs, do it when there's actually not enough RAM. – Triynko – 2013-05-28T15:03:04.010

Answers

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.

skevar7

Posted 2009-08-31T11:57:12.270

Reputation: 925

That registry setting doesn't "turn off paging". It only disables paging for what would otherwise be pageable portions of ntoskrnl.exe and the paged pool. – Jamie Hanrahan – 2015-11-15T01:03:16.637

Don't know about Vista but on Windows 7 I disable paging and has not problems and warnings. This is with 8 or 16GB of RAM. – i486 – 2019-06-21T12:16:52.687

I suspect you had a quirky or slow drive to want that. I have something similar and contrary to what most assume in here, what you did would be a good solution. Increasing the RAM and using minimal or no disk paging might be a more intelligent (and economic) solution than replacing slow media. – j riv – 2013-02-02T17:48:33.807

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

Posted 2009-08-31T11:57:12.270

Reputation: 50 788

5Nothing new to me there. And that's not an answer to my question at all. – skevar7 – 2009-08-31T12:18:25.223

2@skevar7 : Not an answer for you maybe, but good links to explanations about the whole thing for somebody who would find this topic and who wouldn't have as much knowledge as you. – Gnoupi – 2009-08-31T12:59:05.923

1rule of thumb: don't even mention Paging unless it is with absolute certainty related to your problem or if you just want to spark an endless discussion about the DOs and DON'Ts ... same goes for web browsers and anti virus software :) – None – 2009-08-31T13:30:45.267

1I'm absolutely sure paging is guilty, coz perfmon shows hard faults when disk is thrashing. I certainly DO know that turning off paging file significantly improves performance. It's an objective fact and it can be measured. The only problem is that Windows since Vista doesn't want to work in such configuration anymore. – skevar7 – 2009-08-31T13:52:50.193

3@skevar7 : And maybe, just maybe, there are competent people thinking at Microsoft, and they thought and decided that the page file was needed. They haven't done it just to bother you. – Gnoupi – 2009-08-31T13:57:31.980

@skevar7 i was only joking, but that of course doesn't go down well with the believers here, they know no humor when it comes to virtual memory :) check my edited answer, good luck. – None – 2009-08-31T14:26:05.080

All memory is "physical memory" so the wording is a bit confusing but I get it. It could read more effectively with 'slow media memory' even if not so common. – j riv – 2013-02-02T17:44:46.287

Memory refers specifically to RAM, while storage refers to disk. It's like the difference between a "hardware renderer" and a "software renderer", even though both systems involve "hardware". "Physical memory" refers to hardware dedicated to and optimized for memory with addresses. Mapping memory onto a piece of hardware not optimized for the task, such as a hard disk, is therefore not referred to as "physical memory". – Triynko – 2013-05-28T15:08:49.170

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.

Molly7244

Posted 2009-08-31T11:57:12.270

Reputation:

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)

encore2097

Posted 2009-08-31T11:57:12.270

Reputation: 111

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?

UnderLoK

Posted 2009-08-31T11:57:12.270

Reputation: 11

No cleaners.
Sometimes it takes much more time than usually to perform simple operation (5-10 secs) and disk is thrashing. This usually happens after app being idle for some time. Very simple omperations - open new tab in Opera, create new file in Visual Studio, etc. So I suppose Windows paging algorithm is far from perfect. Completely turning off paging file worked well for me in WinXP, but unfortunately Vista and Win7 don't allow that.
– skevar7 – 2009-08-31T12:50:07.177

Unlike many OS's Windows will put up with a fair amount of hardware issues without crashing and it could be that some sort of recovery is going on in the background which is causing the lag. I know it sucks, but run an HD test to make sure it isn’t jacked up as it really sounds like an I/O issue since the problem goes away when you don’t allow the system to use swap.

Check for BIOS updates related to I/O, hd controller, etc. as there could be a known issue.

Does the system take FOREVER to boot (XP, Vista, or 7)? If so, it’s definitely an I/O problem. – UnderLoK – 2009-08-31T15:22:12.517

*I should have said "Windows will put up with a fair amount of hardware issues without notifying you of a problem" ;) – UnderLoK – 2009-08-31T15:23:00.300

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

Posted 2009-08-31T11:57:12.270

Reputation: 5 238

OK, but when you have 8GB RAM and the real need is for 3GB - why is necessary to do any swap to disk? On the other hand, imagine you have 2GB physical RAM + 2GB swap file - how this system works without "explosion"? 4GB are enough for everything but with 8GB physical RAM + 0 swap it is "possible" to have insufficient memory. How? I think the algorithm for virtual memory is wrong from Windows 95 times and it is not changed in Windows 10. – i486 – 2019-06-21T12:20:16.630

2And once again a "my windows does that, how can I...? -> Move to linux" answer. However the rest of the answer is correct, but you could have done without the first sentence. – Gnoupi – 2009-08-31T14:16:38.983