Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!snorkelwacker.mit.edu!bloom-beacon!dont-send-mail-to-path-lines From: mouse@lightning.mcrcim.mcgill.EDU Newsgroups: comp.windows.x Subject: Re: freeing resources Message-ID: <9102271436.AA01369@lightning.McRCIM.McGill.EDU> Date: 27 Feb 91 14:36:28 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 46 > Lately I have been wondering if there are any advantages to freeing > resources when you diconnect from the X server. I mean, before I > make a call to XCloseDisplay() I usually make calls to XFreeThis and > XFreeThat with a liberal dose of XDestroy all around. It makes it easier to lift your code and use it as part of something larger. As far as I can think of at the moment that's the only benefit. There is also an argument on the other side: just closing the display is quick compared to making slew of FreeFoo requests and *then* closing the display. I typically just exit() and forget about the XCloseDisplay(). About all it would buy me is the final XSync(), and I don't care about asynchronous errors 'cuz I'm going away anyway and wouldn't be around to report them! And I don't care about the final XFlush() 'cuz I'm dying on a received event and don't have anything to do except possibly draw in my own window, which is about to go away. > I know that the server will do all of this for me in most cases, All cases, unless you've set your close-down mode (XSetCloseDownMode) to RetainPermanent or RetainTemporary, in which case none of them are destroyed automatically. Modulo bugs, of course. Quoting from the protocol document: At connection close, [...]. If close-down mode (see SetCloseDownMode request) is RetainPermanent or RetainTemporary, then all resources [...] allocated by the client are marked as permanent or temporary, respectively [...]. If the mode is Destroy, all of the client's resources are destroyed. When a client's resources are destroyed, [...save-set processing...]. After save-set processing, all windows created by the client are destroyed. For each nonwindow resource created by the client, the appropriate Free request is performed. All colors and colormap entries allocated by the client are freed. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu