Sometimes I open a program that allocates too much memory - i.e. computer has 0.5 gb free ram, and an application requests 1gb.

In this case, it will start swapping so it can fulfill the request.

Problem is: it is doing extreme swapping, including services' memory, so the computer gets very slow - even the mouse pointer starts stuttering and sometimes I have to power cycle the machine.

It feels wrong to me that an user-mode program, running from a normal user account, can bring the machine down.

Is there some way to say to Windows: hey, if an app requests too much memory put its memory to swap and not essential services' memory.

OS is Windows Server 2012 x64, but I've seen this in numerous other machines as well.

  • 1
    How much ram and how much swap do you have allocated? – Scott Chamberlain Nov 27 '15 at 16:39
  • 2
    There’s no way the swap algorithm would evict recently used pages. Instead, you’re looking at IO starvation. Your storage is just too slow. – Daniel B Nov 27 '15 at 16:53
  • @ScottChamberlain I have 3.5 GB RAM, and the program is Google Earth which sometimes enters a sort of loop and aloocates 4+ GB of memory. – NothingsImpossible Nov 27 '15 at 17:06
  • @DanielB As a test I tried removing the swapfile from the C: drive and moving it to an array of separate, 2 disks combined with striping. It worked - the machine does not hang anymore - so the problem is Swap I/O competing with other I/O on the same disk. But this still bugs me - an unprivileged user mode application can allocate enough memory to trigger swapping, effectively DoSing the machine by preventing other, non-swapping I/O from happening. Is there anyway to prevent this aside from moving the swapfile to another disk - in case there isn't another disk in the machine? – NothingsImpossible Nov 27 '15 at 17:17
  • Having the pagefile on C: along with the OS and program you're running may not be optimal, but should work fine under normal circumstances. Have you tested your C: partition (and the drive it lives on) for errors? – Ƭᴇcʜιᴇ007 Nov 27 '15 at 17:57

In a comment, Daniel B says I was experiencing I/O starvation, so I tried moving the swap-file out of the system partition (C:) and into a separate disk.

It worked - when under memory pressure, the computer does not stop responding anymore. I then decided to do some research on the issue, in order to understand why this happens. These are my conclusions:

  1. In an official Microsoft document titled "I/O Prioritization in Windows Vista", it is stated that I/O is hierarchically processed, and that all critical-priority I/O must be processed before any other priority I/O.

  2. It is also said that critical priority I/O is reserved to the memory manager.

  3. I couldn't find evidence of the existence of any special prioritization by the memory manager based on the owner of a page (i.e. swapping of memory pages allocated by lower priority processes getting lower I/O priority as well).

  4. I couldn't find any evidence of new prioritization strategies in Windows 8.

So, assuming that all memory manager I/O has the same (critical) priority and that the I/O strategy is unchanged since Vista, this is the recipe for disaster:

  • Swap-file in the same disk as the system (usually C:)

  • A process requests more memory than is physically available in the system.

  • Swapping occurs. While swapping is happening, no other I/O operation can take place, even essential I/O by system services or other components of the kernel, because critical I/O is reserved to the memory manager AND all critical I/O takes place before any other I/O.

  • Gradually, every process that blocks on I/O gets stuck. Ultimately the system is effectively unresponsive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.