From: rs AT redplanet DOT com DOT cy (Rotes Sapiens) Newsgroups: comp.os.msdos.djgpp Subject: Re: mem alloc taking up power of 2 Date: Thu, 24 Jul 1997 12:43:16 GMT Organization: Customer of Connect.com.au P/L, Adelaide, Australia Lines: 21 Message-ID: <33d74b66.250677@192.189.54.145> References: <199707171548 DOT IAA02022 AT adit DOT ap DOT net> NNTP-Posting-Host: spider69.cobweb.com.au To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk On Thu, 17 Jul 1997 15:48:07 GMT, Nate Eldredge wrote: >>When I malloc a structure that takes up say 34k, djgpp or dpmi takes >>64k, a loss of 20k. >>So if I allocate 32 structures, I lose 640k. >AFAIK, no you don't. malloc uses sbrk to get memory from the DPMI server. It >gets *that* memory in powers of 2 to reduce overhead, but then parcels it >out to malloc calls as it's needed. So each structure should just be using a >34K block, it's just that malloc grabbed some extra which will be given to >the next request. > >What makes you think you are losing memory? Good point, I tried using different size arrays, and the only memory lost is the unused part of the last 4096 byte page allocated for each malloc. I'm now using short instead of int, it saves a lot of memory. Does anyone know where this !@#$%! six wheeled robot came from? t, after already-trademarked items. They're intended for internal use only (though they always leak out), and they rapidl fall out of use once a product ships, so there's no reason (and in fact would be a great deal of liability involved) why a company would attempt to trademark codenames. -- Erik Max Francis, &tSftDotIotE / email / max AT alcyone DOT com Alcyone Systems / web / http://www.alcyone.com/max/ San Jose, California, United States / icbm / 37 20 07 N 121 53 38 W \ "Love is not love which alters / when it alternation finds." / William Shakespeare, _Sonnets_, 116