I'm hitting a problem whereby X prevents processes from creating windows, uttering something like the following into
cannot open display: :0.0 Maximum number of clients reached
Searching around there are lots of examples of people facing this problem, and sometimes people identify which program they are running is using up all the client slots. See e.g. LP 70872 (Firefox), LP 263211 (gnome-screensaver).
For what it's worth, I run gnome-terminal, thunderbird, chromium-browser, empathy, tomboy and virtualbox nearly all the time, on top of the normal stuff you get with the GNOME desktop, and occasionally some other bits and pieces.
However my question is not "which of my programs is causing this problem" but rather, how can one go about diagnosing this problem?
In the above (and other) bugs, forum reports, etc., a number of tools are suggested:
xlsclients- lists the client applications for the given display, but I don't think that corresponds to 'X clients'
xrestop- a top-style X resources tool, one row per X client. Lots of '' clients, not shown in
xwininfo -root -childrenlists X window objects
From what I can gather, the problem might not be too many clients at all, but rather resources kept around in the X server for clients who have long-since detached. But it would also appear that you cannot (easily?) relate X resources back to their client. Can one effectively diagnose this issue once it has started to occur, or is a tedious divide-and-conquer approach for the apps I run the only approach open to me?
Update Jan 2011: I think I have resolved this issue. For the benefit of anyone stumbling across this, nautilus and/or compiz or something in that chain of software was segfaulting due to a wallpaper I had. I had chosen an XML file as my wallpaper, which defined a rotating gallery of images. It was hand-made, but based on /usr/share/backgrounds/contest/background-1.xml or similar. Disabling the wallpaper and I have not had a crash since.
I'm not marking this as answered yet, since the actual specific problem was not my question, but how to diagnose it was. Unfortunately this was mostly trial-and-error which sucks.