Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!apple!portal!sv!daven From: daven@svc.portal.com Newsgroups: comp.sys.mac.programmer Subject: Re: Off Screen Bit Maps Message-ID: <1990Dec18.210449.6926@svc.portal.com> Date: 18 Dec 90 21:04:49 GMT References: <1990Dec17.212129.27971@morrow.stanford.edu> Organization: Software Ventures Lines: 28 In article <1990Dec17.212129.27971@morrow.stanford.edu> craig@pangea.Stanford.EDU (Craig Jarchow) writes: > Question: How can one use offscreen bit maps that appear and disappear during > a program and avoid heap fragmentation? I notice that > offScreen.portBits.baseAddr must be a pointer, not a handle. Should I allocate > a handle anyway, and lock and dereference it when I need to draw on the > bit map or CopyBits() from it? > > Any wisdom you might have would be appreciated. Actually, there's a tech note somewhere that says that NewPtr is a kinder call than IM I says it is. The memory mgr will allocate the non-relocatable block as low as possible in the heap, even moving relocatable blocks if necessary. So, if you're not going to be creating and destroying a lot of bitmaps, NewPtr should be okay to use. However, your message implied you would be, so using a handle is okay as long as you remember to a) always lock the handle before derefrencing it, b) always update the offScreen.portBits.baseAddr field with the recently dereferenced pointer, c) make certain you always do a & b before any calls that might manipulate the offscreen bitmap, d) unlock the handle when you're done with the bitmap for any length of time. -- ------------------------------------------------------------------------------- Dave Newman | daven@svc.portal.com | AppleLink: D0025 Sofware Ventures Corp. | AOL: MicroPhone | CIS: 76004,2161 Berkeley, CA 94705 | WELL: tinman@well.sf.ca.us | (415) 644-3232