I've been trying for some time to understand the root cause of this problem and think about some way of fixing it. From reading the bug reports listed I keep coming back to this (from https://bugzilla.gnome.org/show_bug.cgi?id=581526):
3) Perform some operation that uses up the XIDs in the X Display's currently available range. (Often there is only one XID available.) Xlib will request a new range of XIDs from the server. Where is the range of XIDs defined? How can the 'currently available range' be determined? Can that range be controlled or configured in some way? -- To UNSUBSCRIBE, email to [email protected] with a subject of "unsubscribe". Trouble? Contact [email protected]

