Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!rutgers!apple!well!wdh From: wdh@well.sf.ca.us (Bill Hofmann) Newsgroups: comp.sys.mac.programmer Subject: Re: MoveHHi or NewPtr? Which end of heap? Message-ID: <21922@well.sf.ca.us> Date: 2 Dec 90 18:38:36 GMT References: <1990Nov30.013939.18568@midway.uchicago.edu> Distribution: usa Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 20 In article <1990Nov30.013939.18568@midway.uchicago.edu> fri0@quads.uchicago.edu (Christian E. Fritze) writes: >I've got ~75K of sound resources which I load into memory early during startup >of my application. These resources are accessed continually during operation >of the app, so I will lock them down in memory for use. > >Question: Is it preferable to lock these away high (after a MoveHi(hndl)) or >instead to try and allocate a nonrelocatable block at the beginning of the >heap with NewPtr()? Which end of the heap is better? Many thanks.\ The answer is, whichever produces the least fragmentation. Using a resource (which gets loaded in as a handle, BTW), and MoveHHi/HLock seems to be a bit better, since typically, if you have a separate segment for your init code, you'll UnloadSeg it when you're done, but then you'll leave a hole in the heap before your non-reloc block holding the sounds. Of course, MoveHHi won't move a reloc block above a locked block if one's in the middle of the heap. When I run into this kind of question, the way I approach it is to carefully step through my init code with MacsBug or The Debugger or TMON and watch what's going on, and adjust code to produce the desired results. -Bill Hofmann