Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!sun-barr!rutgers!cbmvax!peter From: peter@cbmvax.commodore.com (Peter Cherna) Newsgroups: comp.sys.amiga.programmer Subject: Re: Memory fragging Message-ID: <21884@cbmvax.commodore.com> Date: 24 May 91 14:56:45 GMT References: <1991May21.195251.16477@zorch.SF-Bay.ORG> <21795@cbmvax.commodore.com> <886@dvncnms.Devoncnms.Unisys.COM> Reply-To: peter@cbmvax.commodore.com (Peter Cherna) Organization: Commodore-Amiga, Inc. West Chester, PA. Lines: 38 In article <886@dvncnms.Devoncnms.Unisys.COM> efb@dvncnms.Devoncnms.Unisys.COM (Edward Bacon) writes: >How about lists of Gadgets? Here is what I do: >One routine uses AllocRemember() for the gadget, text and image memory. >It calls FreeRemember(TRUE) or FreeRemember(FALSE), AllocRemember() does: AllocMem( a little header ) AllocMem( the block you want ) and then puts tracking information into the little header. FreeRemember(TRUE) disposes of the headers and the blocks. FreeRemember(FALSE) blows away all the little headers, and leaves you with a memory map that looks like *----*----*----*----*----*----*----*----*----*---- Where * = free and - = allocated. Sorta looks like Swiss cheese, or the barn in Black Sunday. Theoretically, the worst thing you can do is allocate a bunch of blocks and free every second block. Sounds a lot like FreeRemember(FALSE). It would be better to hang on the the little blocks and use FreeRemember(TRUE) at the end of your program. It would be _even_ better if Intuition used a memory-pool manager from which to draw the Remember-headers. It would be _even_even_ better if Intuition itself stopped using FreeRemember(FALSE) itself, but that's another topic. Peter -- Peter Cherna, Operating Systems Development Group, Commodore-Amiga, Inc. {uunet|rutgers}!cbmvax!peter peter@cbmvax.commodore.com My opinions do not necessarily represent the opinions of my employer. "If all you have is a hammer, everything looks like a nail."