Xref: news2.mv.net comp.os.msdos.djgpp:852 From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: malloc/free ends up fragmenting dynamic memory? Date: Tue, 06 Feb 1996 07:49:04 -0800 Organization: &tSftDotIotE Lines: 25 Message-ID: <31177870.7944FD77@alcyone.com> References: <4f5sm8$2kt AT cardinal1 DOT Stanford DOT EDU> NNTP-Posting-Host: newton.alcyone.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp John Beale wrote: > I am guessing that the many malloc/free operations fragments the memory > store analgous to hard disk filesystem fragmentation with many saves and > deletes, such that a contiguous memory segment for a large malloc() can no > longer be found. Is there a malloc_unfragment() command or equivalent? How > do other people handle this problem? With pointer-based allocation, there's no way to defragment memory, since you can't move a block of memory _and_ update the pointers which happen to be pointing to (and in) it. On the Macintosh, a whole new level of abstraction is introduced to deal with this problem -- the handle (which is a pointer to a pointer). The solution to this is to either 1. get more memory (not all that unreasonable of a request these days) or 2. devise a way to not fragment memory in the first place (this depends entirely on your application). -- Erik Max Francis, &tSftDotIotE. && max AT alcyone DOT darkside DOT com || max AT alcyone DOT com San Jose, California, U.S.A. && 37 20 07 N 121 53 38 W && the 4th R is respect H.3`S,3,P,3$S,#$Q,C`Q,3,P,3$S,#$Q,3`Q,3,P,C$Q,#(Q.#`-"C`- && 1love && folasade Omnia quia sunt, lumina sunt. && GIGO Omega Psi && http://www.alcyone.com/max/ "Out from his breast/his soul went to seek/the doom of the just." -- _Beowulf_