Mac running out of resources?

I've had my Mac appear to run out of resources a couple of times now and I can't narrow it down to find exactly what is causing it:

I usually notice that this is happening when it refuses to Command-Tab between applications. The task switcher just doesn't come up. It feels like there are no resources left to draw it. None of the open applications will draw menus, or other dialogs, either.

I just had it happen again and FireFox crashed with the following error:

NSInternalInconsistencyException: Error (1007) creating CGSWindow

As far as I can tell, the error seems to back up my observation that either something is causing the window server to fail or the Mac is somehow running out of resources. I've got 4GB RAM and over 175GB of free space on the hard drive so I have a hard time believing that it really is a resource issue.

This time around, I only had TextMate, Twhirl, QuickSilver, and FireFox running when this happened. QuickSilver seems to have crashed, and I shut down Twhirl and restarted FireFox and things seem to be back to normal now. I wonder if one of those three are somehow responsible. At the end of the day, though, this points to a bug with the window server itself as no single application should be able to take affect the whole system like that.

I've had this happen to me on my older MacBook Pro and also on my latest one (unibody).

Have you run into this at all? If so, please leave a comment detailing your experiences. Maybe together we can track down the cause and submit a comprehensive bug report to Apple.

Related reports from around the web: