Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!gvlf3.gvl.unisys.com!tredysvr!dvnspc1!dvncnms!efb From: efb@dvncnms.Devoncnms.Unisys.COM (Edward Bacon) Newsgroups: comp.sys.amiga.programmer Subject: Re: Memory fragging Message-ID: <886@dvncnms.Devoncnms.Unisys.COM> Date: 23 May 91 21:11:57 GMT References: <1991May21.195251.16477@zorch.SF-Bay.ORG> <21795@cbmvax.commodore.com> Organization: Unisys Corporation, Devon Engineering Offices Lines: 24 In article <21795@cbmvax.commodore.com> peter@cbmvax.commodore.com (Peter Cherna) writes: >In article <1991May21.195251.16477@zorch.SF-Bay.ORG> mike@zorch.SF-Bay.ORG (Mike Smithwick) writes: >>[Attack of the killer poodles!] >> >>I am using loads of chip ram and it seems to be fragging pretty badly. So much > [ ... ] >Do as much as you can to free your resources in the reverse order that >you obtained them in. Avoid using FreeRemember(FALSE). Avoid >doing Alloc(A);Alloc(B);Alloc(C), ... , Free(B). > 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), if every thing went OK or not (oops I think I just got that backwards ..). When I go to destroy a window I call a routine that starts with the FirstGadget frees it (and associated text or image) memory and then does the NextGadget. Is this cool or in violation of what you advocated? I am sortta allocating chunks of memory for the gadget and then freeing the chunks, but all of the window's gadget memory chunks get freed in reverse order. What is the problem with FreeRemember(FALSE) ?