"Maximum number of clients reached on X" - Desktop Customization & Workflow

Users browsing this thread: 1 Guest(s)
Grey Hair Nixers
I draw borders on all my x clients with external tools, ala wmutils, so I can do WM-external logic like tags or other visual indicators that the original author did not account for.

Occasionally, all my window borders stop being drawn, and my bg (usually set with feh) stops being set!

Upon poking, I'll usually find something like this as an err message:

~Maximum number of clients reached on X~

Many moons ago I saved this snippet from the internet to find out who is hogging the most clients:

~lsof -U +c 15 | cut -f1 -d' ' | sort | uniq -c | sort -rn | head -3~

And usually I'll find steam or a web browser to a be a culprit, and killing them will free up some connections. My hazy understanding of the situation is there's a limit to the socket connections that can be made to the X server, and even once terminated, those connections take time to expire and free up room for more connections(?) - this problem would be exacerbated by bunches of one off X border draw tool calls, is the only thing I can imagine.

Can anyone explain more clearly why this happens? or if there's some linux socket limit value I can tweak against my better judgment?

It seems to emerge from this (basing it on Xorg-Server for mac which should be the same). if AllocNewConnection fails it then calls ErrorConnMax which will output that NOROOM "Maximum number of clients reached".

AllocNewConnection can fail on either of these cases:

However, in your case it's probably a client limit issue, try setting the maxclients option to 2048 as it seems to be the maximum allowed by X. Even though the manpage Xserver(1) says it shouldn't go above 512, it should still work.

               64|128|256|512  Set  the maximum number of clients allowed to connect to
               the X server.  Acceptable values are 64, 128, 256 or 512.

EDIT: It actually makes no sense to change these values without actually following the current number of opened clients. The most accurate way I've found to list them is:

xwininfo -tree -root
It does it by calling XQueryTree on the root window.

While, for example:
xlsclients -a

Which may sound like it would actually do what is intended, however, it lists the clients found in the WM_COMMAND and WM_CLIENT_MACHINE EWMH attributes on the root window, which isn't accurate at all.
Grey Hair Nixers
Thanks venam, that helps clear some things up -- I'll not change the value for now, and keep in mind to use ~xwininfo -tree -root~ in the future to poke at my hogged clients