After waiting forever for pictures on my laptop to load to show my family, I finally decided to upgrade my RAM from 1GB to 2GB.  I was ready for SCREAMING fast performance.

Then the Windows Shutdown “Hibernate” option stopped working.

“System Error : Insufficient system resources exist to complete the API.”

Now, I live to Hibernate.  Or, I should say I don’t reboot my laptop unless I *have* to.  The computer gets to Hibernate whenever I take it with me so I can resume with all windows and programs exactly where I left them.

I love Hibernate.

But suddenly Hibernate and I were plunged into a Jr High school relationship of drama and fickleness.

Here are the presented options BEFORE, when goodness, happiness and Hibernate reigned:

And then AFTER that vague API failure message, So So Sorry, No More Hibernate!!!

So, listing the symptoms

1) I upgraded from 1G to 2G.

2) Brand new error message, “System Error : Insufficient system resources exist to complete the API.”

3) After said Message of Doom, the option to Hibernate is no longer available in the System Shutdown Options.

4) I recall that Windows forced an update on my last restart.

Background Research

I found that the problem occurs very often with SP2 and was then fixed in SP3.  This upgrade didn’t work for many people, and the problem (and advice) seems to cluster around 2006.  Although this problem is old, the same symptoms are described over at Coding Horror and pcbanter.

Upgrade 1G to 2G = Blotto.

The Hibernate problem is also described here, but has nothing to do with RAM upgrades.  It suggests a network driver install, which I’ll keep on the back burner.

Microsoft’s description of the problem: http://support.microsoft.com/kb/909095

To prepare the computer to hibernate, the Windows kernel power manager requires a block of contiguous memory. The size of this contiguous memory is proportional to the number of physical memory regions that the computer is using. A computer that uses lots of RAM is likely to use more physical memory regions when the computer prepares to hibernate. Therefore, a larger amount of contiguous memory is required to prepare the computer to hibernate.

You see where I’m going with this.  I *did* install more memory but that doesn’t mean I’m using it!  But my computer *does* inform me under Power Options that now I DO need more disk space.

Hypothesis - my RAM upgrade causes this unpleasantness!

Very possible solution - I need 2 Gigs of contiguous disk space fast!

If a RAM upgrade requires a concomitant increase in disk storage space in order to hibernate regardless of the amount of RAM that happens to be in use at the time, then we should try to ensure we have a 2GB area of contiguous memory.

Seems the key is “contiguous” or memory all in one chunk.

Well **sheepish grin** my disk drive is about 87% full.  About 61GB out of 70 GB.  I know, I have to keep clearing stuff out, and I’m pretty diligent about it.  Only 70GB in this day and age, plus I have my music files and pictures on this drive.

Riiiiggggghhht.

Slim chance that 2 of those Gigs actually lining up in a pretty little row for Windows, when only about 7 Gigs are left.  DESPITE that I defrag regularly.

So I have two options to test this hypothesis: 1) defrag again, keeping fingers crossed, and/or 2) free up a nice chunk of memory.  Just defragging may help in the short term, but not the long term if the “2 Gig Rule” is a Windows Thou Shalt.  And since I know I’ve got a lot of unedited photos on the drive, I opted for option 2 (clean up) followed by option 1 (defrag).

But before I started, I did a defrag analysis just to check - the analysis screen shot is below.  And despite very little free contiguous area, Windows reports I don’t need to defrag the disk.  (Although wouldn’t it be cool if Windows were to report back, “If ya wanna hibernate dear user, you might think about a little defrag action ’cause Hibernate ain’t gonna happen with all that new RAM you put in.”)

Nahhh.  Would be too useful.

So Red is fragmented (not sure why), blue is contiguous, green is unmovable files (system files, etc.) and white is free space.  Sadly, not too much white collected all in the same place.  Seems our little theory is holding up pretty well.

Disk on a Diet

I deleted directories of raw picture files that I’d already copied and edited.  Immediately 3MB files deleted in favor of 100K to 300K files.  Then I went ahead and decimated raw files that I hadn’t even edited because they were just house-y pictures and the like - no majestic nature pics I might want to blow up to poster size.

So after an hour or so of bit-wise slimming, my disk drive was down to a svelte 55 GB … 21% full.

Ahhhh, 15 glorious GB Free at Last!

Second, Bring Everyone Together for the Holidays

Drag out the defragger and run it this time.  Below show both the Before (top) and After (bottom) fragmentation information.  Again, Red is fragmented, blue is contiguous, green is unmovable and white is free space.

Glorious white!  A big chunk SURELY enough to satisfy the Windows Hibernate Horde!

Testing the hypothesis

The logical step is to try a hibernate and see what happens - but first, think about how we define success and failure.  Would a successful hibernate be conclusive?  Sigh - not really.  If the computer hibernates, that simply means that (if this 2GB disk chunk theory is correct) I was good for at least one shot.  As one poster mentioned above, his hibernate success rate varied day to day.  It could be that he’s right on the edge of having that contiguous chunk of memory and hops, skips and jumps over the line quite randomly.

So…dare I attempt a hibernate?  Let’s give it a go!

Test Results and Next Steps

Sadness and despair abound.  I was *so* sure this was the fix, but I got the same error message as before.  Also, my connection to the internet is now sporadic (I haven’t rebooted yet since my hibernate “failed.”  Seems my computer is now in an indeterminate state.)

So what to we do with this added information?

1) I could jump in the Way Back machine and uninstall the 2G and try again.  This would tell me if something *else* was the problem, like the Windows update that it insisted HAD to occur before I shut my machine down just before this Hibernate mess started happening.

Oddly, my browser window to Wordpress for writing this post went “offline,” while every other open Firefox window continued happily connected to the Internet.  Hmmm.  A conspiracy?  The ONLY window in which I am doing the debugging?  Surely Firefox isn’t in cahoots with Microsoft.  **cue scary music here**

2) I could dig on the Internet some more.  Maybe the chunk of disk space needs to be somewhere specific on the hard drive?  Maybe in the first 1G area?

3) Oh sadness … it may be that with 2GB, Windows has lost the ability to hibernate completely.

4) Try that network reinstall suggestion I read about, although it mentions nothing about RAM upgrades being involved with that hibernate symptom.

5) Go to the gym, try out my brandy-new running shoes, and think about it for a while.  Often this is the best debugging advice of all.

Did you test enough, oh foolish debugger?

Turns out the *very next time* I tried to Hibernate after the *crossed fingers* scenario above, it worked!

Huh?!?

But then a couple days ago, “System Error : Insufficient system resources exist to complete the API.”

Over the next week or so, Hibernate behavior was a coin toss.  Then I figured I’d look at the defrag report again.

Bad Bad Windows

Aha! Look what happened to my nice big white chunk of free memory.  See that skinny red line right in the middle of the white free space?!? Windows has shoved a fragment of SOME OTHER FILE right in the MIDDLE of my 2GB of contiguous memory!!!!

Lather, Rinse, Repeat Testing

So clearly, additional testing is required.  I repeated my last test - defrag, verify big white chunk of disk space, attempt hibernation.

Here is the post defrag, which DID lead to a successful hibernate:

But again after another Hibernate Failure last night, time to recheck.  Now I know - check the disk - the report is below.  Damn that Windows for plopping file fragments in the middle of the Great White Diskspace Way.

So what to do now?

Bug Kinda Nailed

I’m not a Windows expert, so I’m not going to speculate what Windows does after it hammers me by dis-contiguous-ing my disk space, and then hammers me by refusing to Hibernate.  However, looking at the services running with Process Explorer at the time of failure and just after, I can see several services that are likely related.  A spike in both CPU usage and I/O usage is caused by winlogin.exe (me attempting to Hibernate), followed shortly by activity from svchost.exe - specifically, SEM or System Event Notification.  This monitors and sends (publishes) events in several areas including network connect/disconnect notifications, how the user interfaces with the system - actions like logging on or off, locking or unlocking the screen, screen saver, and pressing CTRL-ALT-DEL, and power state notifications.

Makes sense - I (the user) made a request which was detected.  And then denied.

What’s Next for the Hibernate war?

Well, I got Hibernate to start working again after my 1G to 2G upgrade by slimming down the hard drive and defragging.  I will continue the disk diet, but I’m not completely confident.  Based on what I’ve read online, this is a bug within Windows itself, and I can’t debug Windows from the inside.  All I can do is assess the debris trail (aka, “Black box testing”).

I’ll have to let you know after I free some more space and run some more tests.

Anyone have new suggestions?