Hack #35. Manage Windows System Resources

Windows System Resources have been misunderstood and maligned for years. There isn't much you can do about them but change your software.

Many "out of memory" errors, specifically "out of resources" or "low on resources" error messages, on Windows 95, 98, and Me have nothing to do with how much RAM is installed in the system but how well specific portions of it are managed. The specific portions of RAM I'm discussing here are the system resources. Why Microsoft allows Windows to issue the same "out of memory" error for low resources that it issues for actually having too little system memory to run a program is anyone's guess; they know better and so do we.

System resources are (poorly documented) bits of memory that Windows 95, 98, and Me play with internally. They comprise three fixed-size 64 KB blocks of RAM known as the GDI, User, and System resources, each used for a specific purpose within the operating system. The GDI (Graphical Device Interface) is used for communicating graphical device instructions and is not usually implicated in "out of memory" or "out of resources" error conditions. System resources are rarely implicated in these conditions, as Windows manages this block pretty well for itself. User resources, on the other hand, really are not under user control but used at the whim of applications that PC users use.

Each resource in Windows 95/98/Me is limited in size as well as in the number of processes or blocks of each range that can be used (16). Programs may request and use blocks of available resources on a temporary basis, primarily for moving small amounts of data between other applications or storing them for themselves. Windows will manage and keep track of resource use, but not if a resource is no longer needed by the program that requested it. If a program closes or crashes and fails to tell Windows that the resources it used can be relinquished back to other uses, Windows never knows the difference. If you restart one of these errant programs and close it again, or if it crashes and keeps the resources tied up, the problem gets worse, since a new block of data is consumed while the old one is never released.

If all of the system resource allocations are consumed, no other program can use them, and you could encounter a mysterious "out of memory" or "out of resources" error. Since Windows has no way to know if the program that used a resource allocation no longer needs it, the condition will not improve without a reboot.

Windows 95, 98, and 98SE (see also the upcoming section "How Systems Resource Use and Tracking Changed Under Windows Me") keep pretty tight tabs on the amount of resources that are available and in use. You can monitor system resources and, as a result, the behavior of your application programs with regard to resource use and cleaning them up by using Windows's System Resource Meter program, RSRCMTR.EXE. To use the System Resource Meter, first install it by following these steps:

  1. Click Start, select Settings, and then select Control Panel.

  2. Double-click Add/Remove Programs.

  3. Select Windows Setup and then double-click System Tools.

  4. Click System Resource Meter and then click OK twice.

Access the System Resource Meter tool by either of these methods:

  1. Click Start and select Run.

  2. Type in rsrcmtr.exe and then click OK.

Or:

  1. Click Start, then select Programs.

  2. Select Accessories, then System Tools, and then Resource Meter.

The first time you run the System Resource Meter, you will receive a dialog like that of Figure 4-1 alerting you to the fact that Resource Meter itself consumes some resources, just to let you qualify your results knowing each tool you use may impact the readings.

Resource Meter warns you that it too uses system resources

Figure 4-1. Resource Meter warns you that it too uses system resources

Resource Meter displays a bar graph and percentages of each respective resource used, as shown in Figure 4-2. The measurements are an aggregate reading of the amount of memory consumed by resource use and the number of resources allocated.

Resource Meter showing very little resource use

Figure 4-2. Resource Meter showing very little resource use

Many programs will monitor resources on their own and may indicate that insufficient memory exists to run if any of the measured resources gets below some internally defined percentage, even though the program may not need to use more resources than it takes to start the program and test for available memory. This condition causes a lot of support calls and fruitless efforts to add more memory.

Tip

Unrecoverable or unreleased system resource abuse is one of the reasons Windows users feel the need to reboot so often, and rightfully so. Exiting some programs does not immediately or always release the resources they used—bad programming and the poor resource management of Windows are to blame. In cases where stubborn applications fail to release resources, restarting the system is the only way to get a "clean slate" of resources.

Some users watch the resource levels like hawks over new prey in hopes of participating in regulating the use of these resources and trying to keep as much of them available as possible. Manic users establish some self-imposed threshold levels on how much resource usage is too much, nearly panicking if a newly loaded program runs the bar up "too high" or if resource use doesn't drop immediately once a program is terminated.

Preying on this memory-monitoring tech anxiety are many utility software programmers who create RAM management programs such as RAM Idle, RAM Booster, MemTurbo, Mem Free, FreeMem, and the like. These programs try to intervene in the process of knowing which programs use the resources when they are run and try to clean up after them by forcing the resources free if a program terminates without doing its own housekeeping. Oh the wasted anxiety of it all when, in fact, there is very little a user can do to control specific resource usage, especially since such memory management programs also consume resources and CPU time and often conflict with Windows's own memory management functions. I really do not advocate the use of these programs for these reasons.

While the "sticky resource" problem is allowed by Windows it is almost certainly caused by improper application development. Instead of fighting resource issues with Windows 95/98/Me, you can avoid them by:

  • Monitoring Resource Meter and experimenting with each application you use to determine its resource use and if it frees up resources when terminated. Any program that does not clean up when it exits is a program that should be avoided at all cost; if the people who created the program cannot manage memory use properly, you have to wonder what else they neglected. Look for an upgrade to the application and specifically for an upgrade that indicates it has solved its resource-hogging problems.

  • Upgrading to a version of the program or a new operating system (like Windows 2000 or XP) that does not have issues with these legacy resources.

  • Unfortunately, rebooting at least daily. This is the way to absolutely assure that resources are cleared after use and provide a fresh start for your applications.

How Systems Resource Use and Tracking Changed Under Windows Me

Knowing that System Resource management under Windows 9x was inadequate, when Microsoft created Windows Me, they broke the system resources mold, ground it up into tiny pieces, and burned it. The biggest problem with fixed-resource allocations was not so much the 64 KB limit but that only so many blocks of any size (up to 64 K) could be allocated. So, if more than 16 programs needed resources, the system immediately "ran out" of them. With Windows Me, Microsoft replaced the static 64 KB System and User Resources with dynamically allocated and managed schemes that allowed nearly all system RAM to be used as resources by unlimited numbers of programs.

Resources could be allocated to as many programs as needed them, and they could take up to the limit of available RAM memory, though no program probably ever put a dent in the many megabytes of RAM most Me systems had available.

Given Me's unlimited resources, you might think that a program would never produce an "out of memory" or "out of resources" error message and fail to run. Unfortunately, programs that kept track of Windows's resources did so unnecessarily (because they were designed for 95 and 98, where resources were limited) and did so with the only tool they had—the same data the Resource Meter used, which under Me is completely erroneous.

Resource Meter and similar measurements based resource limits on the percentage of memory used and allocated. Under Windows 95 and 98, a system running either 8 programs of 16 maximum or using 32 KB of the total 64 KB of resources indicated that 50% of resources were free. Under Windows Me, if just one program used 32 KB of resources, Windows allocated 32 KB, which is 100% of the available resources (allocated at that time), and Resource Meter would always indicate 100% use no matter what. A program that checks resource use would see 100% use, determine that no resources were available to it, and might kick out an error message instead of knowing it could have requested a resource allocation and gotten it.

And no, Microsoft did not update the Resource Meter program for Windows Me, nor did they openly publish this information for developers or users. Indeed, Microsoft did publish a paper about the change in resource allocation methods, but for some reason the paper quickly disappeared off their web site after enough attention was called to the matter, which is unfortunate because it explained a lot of things and would have allowed programmers to correct their software accordingly. Windows NT, 2000, XP, and Windows Server 2003 have unlimited resources using a completely different style of memory management from Windows 9x and Me, and these NT-based operating system do not have resource problems.

Get PC Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.