Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!decwrl!ogicse!mintaka!bloom-beacon!dont-send-mail-to-path-lines From: mouse@lightning.mcrcim.mcgill.EDU Newsgroups: comp.windows.x Subject: Re: resource ID allocation Message-ID: <9102140823.AA17984@lightning.McRCIM.McGill.EDU> Date: 14 Feb 91 08:23:02 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 59 > I've been pondering the allocation of resource ID's. > I understand how a window allocates an ID and sends a request to the > server for creating new resources. I also understand that the server > checks to insure that the id is a valid one. > But what I don't understand is what happens if a client continues > creating and destroying resources to the point of using up all of the > valid ID's. It can't, in one sense. Once a resource has been destroyed the ID can be reused. The protocol document says: The resource-id-mask contains a single contiguous set of bits (at least 18). The client allocates resource IDs for types WINDOW, PIXMAP, CURSOR, FONT, GCONTEXT, and COLORMAP by choosing a value with only some subset of these bits set and ORing it with resource-id-base. Only values constructed in this way can be used to name newly created resources over this connection. [...] The client is not restricted to linear or contiguous allocation of resource IDs. Once an ID has been freed, it can be reused, but this should not be necessary. "should not" because creating 262144 resource objects over the life of a program seems a bit excessive. But if you must, you *can* reuse XIDs. (If you have a client that is perverse enough to want to have more than 262144 resource objects in existence simultaneously, you will most likely have trouble. Such clients cannot be fully portable, though they may work on servers that give out resource-id-masks with more than 18 bits set.) > Does X have some mechanism for resetting the resource_id member when > it overflows into the SERVER_BIT? This is an Xlib issue. I don't know, but I suspect not. It seems unlikely, simply because nobody would ever dream of its being necessary. > If not, clients which manage a lot of resources for a long time may > run out of valid ID's. This seems like a silly thing to worry about. However, suppose someone has some program running for weeks, creating and destroying windows, GCs, whatever, and then as it gets old, it crashes when its Xlib creates an invalid XID...unless Xlib does get this right, of course! (I haven't checked the source.) Hmmm, 262144 XIDs, that would mean 8738+ a day in order to run out in a month, which, in turn, means one every 9.9- seconds (8738 XIDs per day / 60*60*24=86400 seconds per day = 1 XID per 9.8877- seconds). That's on the average, over the whole month. Hmmm, perhaps it's not something we have to worry about after all. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu