How does Windows deal with process memory or resource exhaustion?

0

The other day I was working on a Windows 7 32-bit PC, with a few applications running including Firefox.

Over time I kept opening new tabs in Firefox until, suddenly, the Firefox window started flickering. From that point, most of Firefox's GUI turned black and refused to repaint. After trying to blindly close some tabs, the Firefox process crashed entirely. All other applications seemed to continue to work just fine.

I'm assuming (correct me if I'm wrong) that the Firefox process exhausted its 2GB virtual memory entitlement or some other resource. Which brings me to the key questions:

  1. Can memory/resource exhaustion in one process de-stabilize other processes or even the kernel itself?

  2. How does modern Windows deal with this scenario? How robust is it under these high-pressure conditions?

My concern is that, if other processes or kernel services are compromised, that could conceivably result in a broken system (e.g. file/disk/registry corruption).

misha256

Posted 2015-07-04T08:00:37.483

Reputation: 10 292

Answers

1

How does Windows deal with process memory or resource exhaustion?

How a program behaves under "stress conditions" depends on how the particular program has been written (what privileges it has, does it contain bugs, etc) and this behaviour will determine how the rest of the system is affected when something "goes wrong".

It is possible that data can be lost. It is possible for the system to crash with a BSOD or just be unable to write data because of a delayed write failed error.


Pushing the Limits of Windows

The blog post series by Mark Russinovich (starting at Pushing the Limits of Windows: Physical Memory) goes into this topic in some detail.

In particular, in Pushing the Limits of Windows: Paged and Nonpaged Pool, he illustrates the effect of running a test program:

If you want to witness first hand how a system behaves when pool runs low, use the Notmyfault tool. It has options that cause it to leak either nonpaged or paged pool in the increment that you specify. You can change the leak size while it’s leaking if you want to change the rate of the leak and Notmyfault frees all the leaked memory when you exit it

On one test system, he said about the results:

On one test system, I eventually saw this error message indicating that data had potentially been lost. I hope you never see this dialog on a real system!

enter image description here


Further Reading

Windows Internals, 6th edition by Mark Russinovich contains a lot more information on how Windows works under the hood.

DavidPostill

Posted 2015-07-04T08:00:37.483

Reputation: 118 938

Wow, nice references, very rich information. Reading through the articles, I suspect my case was GDI or USER object exhaustion (the clues being black window & GUI not repainting). I don't think Firefox tabs of web content would exhaust kernel resources (paged/non-paged pools)? – misha256 – 2015-07-04T08:59:43.980

@misha256 It depends on what is happening in the tabs. A badly written plugin for example could be leaking GDI resources, or it could just be a bug in firefox. How many tabs did you manage to open? What type of content was dislayed in the tabs? – DavidPostill – 2015-07-04T09:02:04.093

At a guess, perhaps 20~25 tabs, each tab would have had reasonably rich content including Flash animation/video (all those Flash ads don't help either). – misha256 – 2015-07-04T09:05:15.650

So it could be a bug in the flash plugin. – DavidPostill – 2015-07-04T09:06:15.927

Bugs in Flash? Why doesn't that surprise me. – misha256 – 2015-07-04T09:06:48.773

By the way, did you get a firefox crash report? That normally gives a pretty good idea of where and why it crashed. – DavidPostill – 2015-07-04T09:12:31.690

You've helped enormously. Especially the Russinovich reference, which leads to a whole bunch of excellent utilities - something to play with in a virtual machine :-) – misha256 – 2015-07-04T09:12:56.150

did you get a firefox crash report? Not at the time... silly me... but wait, Windows 7's excellent Event Viewer has a record: Faulting application name: plugin-container.exe, Faulting module name: mozalloc.dll. Handy! – misha256 – 2015-07-04T09:19:16.177

1about:support will give you access to past crash reports (click "All Crash Reports") ;) – DavidPostill – 2015-07-04T09:21:21.157

1

Last comment, I just found this, which may explain why my other processes continued to work fine even when Firefox went belly-up: http://blogs.msdn.com/b/oldnewthing/archive/2007/07/18/3926581.aspx

– misha256 – 2015-07-04T09:33:22.777