Back in the bad old days of Windows 95, 98, and Me, we used to have to carefully consider the usage of system resource handles (user and GDI) even more carefully than we worried about memory usage. Tech support people repeated often the canard that most of the time when people talked about their system being out of memory it was really resource handles they were running out of. After all, you could buy more memory, but not more handles.
Then Windows 2000 promised to rid us of that problem, and we blissfully set it behind us. The heap from which resource handles were allocated was not only a lot bigger, it was also handled dynamically a lot more efficiently so you should have no need to worry about handles. And for many years, there was much rejoicing.
Without a lot of fanfare, the resource problem has crept back into the world, and since it's been sneaky, a lot of people who suffer from it -- even tech support workers who became intimately familiar with the problem a decade ago -- don't realize that that's what's happening. It's not that XP, Vista, or even Windows 7 have reintroduced the limited resource heap of Windows 95. It's just that, spoiled with having plenty of room and no serious limits, programmers have become even more sloppy and undisciplined than they were back in the old days. As resource usage has grown and programs have gotten worse at cleaning up after themselves, the vastly larger and more efficient heap of Windows 2000, once seen as nearly inexhaustible, can now be exhausted in a single day's work.
By far the greatest villain of the piece is Firefox, and this is why this problem has become painful for me: back in May I switched from Opera to Firefox and it wasn't immediately obvious that that's why I started having problems whenever my computer stayed up and running for more than a few days. Usually, I reboot every morning and evening as I move my laptop to and from work, except on the weekends, when it might stay up three days straight. But after a couple of months, three days proved too long: I started having mysterious program crashes, error messages, and screen redraw problems. As of a month ago, I couldn't go a whole day without having this happen, and I was resigned to a daily reboot.
I finally got fed up and did some research online, and discovered the hidden resource handle problem. Some sources are saying that most users are having these problems and don't know it, and most of those "does a reboot fix it?" problems are really just resource handle problems. A registry hack increases one of the pools and offered me some temporary relief, but what really did it was using Process Explorer to watch what programs were using a lot of resources, and it was eye-opening.
Firefox with only a handful of extensions starts with 300-400 GDI objects, but open and close a few tabs and it balloons to 800 almost instantly. Those objects, once allocated, never seem to be freed. A few hours of use and you can easily see 1500 objects or more. Close Firefox, open it again, and reopen the same tabs, and that drops to 400 once more. In fact, closing and reopening Firefox every few hours will more than double how long my computer can go between reboots.
There's no reason it should be this way. A properly written program will return resources it's not using with precisely the same regularity as it allocated them in the first place, so its resource usage remains mostly constant. Forté Agent, for instance, holds steady at around 500 no matter what I do with it, for days at a time. Closing and reopening it does nothing to improve my system performance since it's already cleaning up after itself nearly perfectly.
But Trillian, Feedreader, zMUD, and by far the worst, Firefox, are hideously wasteful about resources. Closing and reopening these programs periodically make a very evident improvement in my system performance and delay the time when I need a reboot until I can keep my computer up through the whole weekend. In fact, being home sick last week, I had my computer up with two reboots for a solid week.
So if you're having mysterious problems with your computer which get worse as time passes between reboots, and which clear up on a reboot, check your resource usage or just try closing and reopening programs. And if you're a developer, by all that's holy, fix your programs already. Freeing resources is first-semester stuff. You're not too good to handle the basics.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment