Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!stevec From: stevec@Apple.COM (Steve Christensen) Newsgroups: comp.sys.mac.programmer Subject: Re: Why does this work? Message-ID: <48364@apple.Apple.COM> Date: 22 Jan 91 21:03:55 GMT References: <2899.279c25a4@iccgcc.decnet.ab.com> Organization: Apple Computer Inc., Cupertino, CA Lines: 30 milikich@iccgcc.decnet.ab.com (Mike Milikich, Allen-Bradley Company) writes: > > I guess the MoreMasters thread isn't dead yet! > > As part of a data acquisition app in Think C, I set up a list of blocks >of memory linked by their handles. Without ever calling MoreMasters (), I link >up 100 of these things. I did this on purpose at first to make sure I knew what >the MoreMasters () call would do. Obviously, I don't - the things works fine. >Why can I get 100 handles with calls to NewHandle () ? If it matters, this is >on a IIcx with 8 meg. You never *have* to call MoreMasters(), but it's provided for more intelligent heap management. If you call NewHandle() and there are no more free master pointers, then MoreMasters will be called to create a new MP block. Being that the MP block is non-relocatable, it will be created as close to the beginning of the heap as possible--which may not be that close if a bunch of other blocks (non-relocatable and/or locked relocatable) already exist. If some of those relocatable blocks are unlocked and move, then the MP block becomes an island in the heap, effectively fragmenting it into two pieces. If you call MoreMasters one or more times when your program first starts up, then the MP blocks will be created very close to the beginning of the heap, reducing the chances of heap fragmentation... steve -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Steve Christensen | Apple Computer, Inc. | Disclaimer: | 20525 Mariani Ave, MS-81CS | the above may be stevec@apple.com | Cupertino, CA 95014 | a lie...or not.