From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c70f02b79bc3d231 X-Google-Attributes: gid103376,public From: jsa@alexandria.organon.com (Jon S Anthony) Subject: Re: dynamic memory allocation Date: 1997/06/18 Message-ID: #1/1 X-Deja-AN: 249402863 Distribution: world References: <33A55F1B.63FE@gsfc.nasa.gov> <33A7B0B4.F75C277D@elca-matrix.ch> Organization: PSI Public Usenet Link Newsgroups: comp.lang.ada Date: 1997-06-18T00:00:00+00:00 List-Id: In article <33A7B0B4.F75C277D@elca-matrix.ch> Mats.Weber@elca-matrix.ch writes: > > Whether it's bad or not will really depend on the specifics of the > > application and the memory manager. If the MM coaleces or compacts, I > > don't see how _fragmentation_ will be a problem. [...] > > Should be "coaleces _and_ compacts". Well, no that is certainly not right. If it compacts, coalecing is irrelevant. So, I guess you could claim that "if it coaleces, then it needs to also compact". > If it coaleces xor compacts, it is easy to construct a program that > runs out of memory due to fragmentation. Not for the compaction disjunct. No way. > Moreover, compaction is quite unlikely to happen on most > implementations as it requires a double indirection or a GC-like > scanning of all live pointers. Yes, I would agree with this. > What we do to minimize fragmentation is to allocate only blocks with > sizes that are powers of two, and maintain one free list per power > of two. It does waste some storage but the program runs well for > long periods of time. Yes this is a pretty standard trick (with various bases). Buddy systems are related, and they coalesce, and for an appropriate base for your application, should avoid fragmentation issues reasonbly well. /Jon -- Jon Anthony OMI, Belmont, MA 02178 617.484.3383 "Nightmares - Ha! The way my life's been going lately, Who'd notice?" -- Londo Mollari