Subj : Re: malloc() To : borland.public.cpp.borlandcpp From : waking Date : Fri Jun 25 2004 06:39 am On Thu, 24 Jun 2004 19:53:06 -0700, Bob Gonder wrote: >I had fragmentation issues with FIFO free. Hmm, not sure if it was actually as you describe. Certainly, the heap manager never optimized by defragmenting automatically. There were 3rd party memory managers available which would do that. However, programmers often misinterpreted what was happening because they used coreleft() or farcoreleft() to check the effect of freeing allocations. This could be misleading when the heap is fragmented, since those functions only show the available memory *from the highest allocation* to the top of the heap. They don't include free blocks interspersed between allocated blocks. To include them requires a heapwalk. This issue was addressed in a Borland TI bulletin. See: "Getting Amount of Available Memory on the Far Heap" http://www.vmlinux.org/~jakov/community.borland.com/15439.html "Free Memory on the Far Heap" http://www.vmlinux.org/~jakov/community.borland.com/17160.html The above two have essentially the same code. The following is more comprehensive as it combines near and far heaps in its report (when the memory model has two heaps): "Function that returns the total heap memory" http://www.vmlinux.org/~jakov/community.borland.com/16688.html >Releasing 2 next would add 2 to 3/4, but didn't >go "down" the chain and reclaim 1. I've never seen that in tests I conducted over the years with similar scenarios and various compilers. (Which doesn't mean it *never* happened, of course.) -- Wayne A. King (waking@idirect.com, Wayne_A_King@compuserve.com) .