Working with Hundreds of Windows
Working with hundreds of windows in your windowing system, without losing track of them, never stopping work, keeping it all nicely organised and comfortable.
It's not uncommon to have to work on several projects at the same time. And to never to turn off one's computer, achieving over a year of uptime thanks to suspension and hibernation. And to never even log out, but only lock the screen. All this goes hand in hand with having hundreds of windows opened at all time.
1 Hundreds of Windows
I've been living happily for some months now having more or less 300 windows opened constantly. How this can be achieved realistically with tiling window managers, window lookup functions and a suitable use of workspaces is beyond the scope of this note, however. There's a harder limit I wanted to address here, which is how many clients the X.Org Server is capable of opening at the same time.
2 256 Clients
By default, that's 256 clients. And I mean 256 clients. A client is not necessarily a window. It can be an OSD message, a dockable applet, a Firefox pop-up and I believe even an SSH session opened with -X
. It's a limit that can be reached rather quickly.
There are tools to track clients, such as xwininfo
and xrestop
. They can be used as follows:
xwininfo -root -children
xrestop
Googling for maximum number of clients reached leads to the How can I diagnose/debug “maximum number of clients reached” X errors? question, which refers to these tools. They will give you an idea of how resources are spent, although what they report is still not all clear to me. Anyway, the fact of the matter remains: the 256-clients limits must somehow be raised.
3 Patching X.Org Server
... was much easier than I thought it would be. I've been working for over a year without problem with this effective change. The maximum number of clients that can be opened in X Window is dictated by the MAXCLIENTS
constant in the /usr/include/xorg/misc.h
file – which you'll find is set to 256 clients, then. This can be increased to 512, probably not more however, as there are somewhere else in the code conditionals depending on this constant going up to 512.
To patch X.Org Server and repackage it, all you need to do is:
- Download the
xserver-common
original source, and the Ubuntu patch which you'll apply. Edit
include/misc.h
accordingly. No need to create a patch for the change to be picked up:#define MAXCLIENTS 512
- Run
debuild binary
. Install all the generated packages (except for the
udev
one).
4 Outlook
Googling for xorg increase MAXCLIENTS leads to the Xlib: maximum number of clients reached discussion which also suggests changing Xpoll.h
. I didn't find that to be necessary. And Googling for xorg maxclients leads to the xorg.conf (5) manpage: it refers to a MaxClients
option which isn't mentioned in all installed manpages. Anyway, it doesn't play any role in this recipe either.