From: "Campbell, Rolf [SKY:1U32:EXCH]" Newsgroups: comp.os.msdos.djgpp,comp.games.development.programming.misc Subject: Re: Compacting the Memory Date: Mon, 16 Aug 1999 11:48:43 -0400 Organization: Nortel Networks Lines: 26 Message-ID: <37B832DB.C9CEA122@americasm01.nt.com> References: <7p974q$4gg$1 AT news6 DOT svr DOT pol DOT co DOT uk> NNTP-Posting-Host: bmerhc00.ca.nortel.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.7 [en] (X11; I; HP-UX B.10.20 9000/712) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Ben Davis wrote: > I am writing a program in DJGPP C, which uses the memory VERY dynamically: > there are loads of malloc()s and free()s. They occur in a strange order, and > some are quite large. If two blocks are allocated, and then the first one is > freed, and then a third, larger block is allocated before the second one is > freed, some memory is wasted (I fear). > What I would like to know is, does DJGPP automatically compact the memory by > moving blocks down to fill all the gaps, or do I have to do it manually? How > can I do this? The memory management system with DJGPP does not defragment memory. But, don't worry about it, none of the memory really gets wasted. There may be blocks of memory temporarily unused, but if you do a small allocation later, it will likely come from one of those 'wasted' blocks. Also, remember the apparent order of memory (from your programs perspective) is not neccesarily the real order. The DPMI server will likely page-out those unused memory blocks to disk if you don't use them for a while and you are allocating more memory than you physically have. -- -Rolf Campbell (39)3-6318