Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!maverick.ksu.ksu.edu!rutgers!mcnc!rti!bcw From: bcw@rti.rti.org (Bruce Wright) Newsgroups: comp.windows.ms Subject: Re: Space for pens, brushes, and other objects Summary: Objects &c Message-ID: <4101@rtifs1.UUCP> Date: 26 Sep 90 04:29:21 GMT References: <4941@hsv3.UUCP> <4942@hsv3.UUCP> Organization: Research Triangle Institute, RTP, NC Lines: 37 In article <4942@hsv3.UUCP>, jls@hsv3.UUCP (James Seidman) writes: > > Where in memory are objects stored? I'd most like to know if they're > handled in such a way that they are automatically disposed when an application > terminates, or if they always need to be explicitly removed with > DeleteObject(). I haven't tried this on Windows 3, but under Windows 2 objects are definitely NOT disposed of when the application terminates. I was writing an application once that created LOTS of pens and brushes, but there was a minor bug in the algorithm that ran around and deleted the old ones after it was through with them. After a while things got VERY strange ... all sorts of odd things would start to happen (not just in that program, and even after the program had exited). I'd be sort of surprised if Windows 3 added this sort of resource management - it's going to take significant space on the smaller machines, and Win3 just doesn't take up all that much more space in memory (some of the mini-apps distributed with it are a different story, but they're not the basic system itself). But I haven't really been interested in putting this to the test. > On a similar note, do you have to use DeleteObject() to remove an object > obtained with GetStockObject()? (In fact, is it even considered valid > to do so?) It is not valid to do a DeleteObject on objects you obtain with GetStockObject. Also, be sure that any objects you delete aren't selected into the current Device Context (or they won't be deleted). Windows doesn't do much resource management for programs - you need to explicitly delete anything you create (device contexts, pens, brushes, timers, etc), though of course they are created and deleted in different ways. But not keeping track of them properly is one of the easiest ways to wedge the system - Bruce C. Wright