I'm not sure how _XAllocID should work. Could anyone explain me it, or send a link to documentation? Where those IDs are de-allocated ? _XIDHandler can be called only once, and Ican't find any other code changing dpy->resource_id. Why there is a code: if (id != 0x10000000) { .... } resource_mask and resource_max are much smaller than 0x10000000