Windows XP seemingly out of resources but plenty of free RAM and swap available

Posted on

QUESTION :

This one has been bothering me for years and so far I couldn’t find an adequate solution.

The problem occurs on pretty much every XP install I’ve done. After opening a variety of programs or the system running existing programs for a while, Windows seemingly runs out of resources, without telling me.

There’s ALWAYS free RAM. For example, it just happened to me and I had over a gig of free RAM. There are no viruses, spyware, or other nonsense – it is a Windows resource problem, but the question is which resource is it running out of, how does one pinpoint it, and how does one prevent it?

Sometimes, this happens after running specific programs – for example, today it happened when I started Photoshop CS4 and Flash CS4 at the same time. I also noticed that restarting The Bat (email client by Ritlabs) seems to get rid of this problem for a while but again, this happens on machines that don’t even have The Bat installed.

So what does exactly happen? The symptoms are:

  • pressing alt-tab doesn’t bring up the list anymore – it just jumps to the next window instantly, very similar to the way Alt-Esc works, however in this case, it’s due to not having enough resources to bring up the alt-tab menu

  • random programs would randomly crash, citing random errors, out of memory errors, system resources, inabilities to do system calls, etc.

  • random programs would start missing random parts – for example, Firefox top menus might disappear, pull up partial selections, or not pull up anymore altogether. IE might lose a few of its toolbars. Some programs might fail to redraw or would just plain go gray where the UI used to be.

  • Windows itself never complains about running out of RAM, virtual memory, or anything at all, yet it’s running out of something.

The only clue I was able to find and apply the fix today was this Desktop Heap Limitation. I haven’t confirmed the fix working as not enough time passed. In the meantime, what are everyone’s thoughts?

ANSWER :

Could be a handle leakage in a program you have running. I had a bug in one of my programs that exhibited these problems, bringing up new programs would have problems with missing or incomplete toolbars, file->open dialogs not showing, alt-tabbing not working properly, and strange errors, etc.

In Task Manager you can use the View->Columns menu to show columns for handle as well as user and gdi objects, which both uses handles, if you find a program with a high number there, it could be the culprit.

Unfortunately, what exactly a “high number” is depends entirely on the program.

In particular, pay attention to any program for which the handle count is steadily increasing, as this might indicate such a leak.

That’s because Windows has so called “desktop heap” where most of the GUI objects are living, menus, icons and what have you. And this space is pretty limited, and, what’s more important, fixed in size.

See Q126962: On the desktop heap for solution and read Raymond Chen for some more information.

The term “resources” or “system resources” on Windows refers to various objects (such as window handles) inside the operating system. Windows limits the space allotted to resources, so that they cannot use all of system memory. That is why you have plenty of free memory but not enough resource space.

Mark Russinovich and David Solomon (of Winternals and Sysinternals fame) have written a book that details the guts of Windows thoroughly: Windows Internals. The fourth edition covers Windows 2000, XP, and Server 2003, and it is available by itself or as part of the Windows Server 2003 Resource Kit. The fifth edition will be released in June 2009, and it will cover Windows Vista and Server 2008. One or both of these volumes may be of help for you, but be warned: This is not just a Saturday-afternoon read!

Drivers, and other stuff far enough down to be playing in or around the kernel, can cause big problems when they’re not working properly — and it’s a bottleneck that’s not always visible in the obvious CPU, memory, or disk I/O paths.

Leave a Reply

Your email address will not be published.