Michael G Schwern <[EMAIL PROTECTED]> writes: > >But you're not. You're just exposing sbrk(), which is a gory detail. My >sbrk man page describes sbrk as being used to find "the current location of >the program break" which means nothing to me. Nor does "returns the current >memory top". > >It'll be even worse on an OS which doesn't have sbrk, which means no sbrk(2) >man page to look at.
A very important point. > >Does sbrk() just return the current number of bytes allocated to the >program? No. It returns the (virtual) address of the end of the "data segment". Most (but not all) UNIX malloc()s get memory from the OS by moving this up to make data segment bigger. So differences in sbrk(0) returns indicate how much memory has been grabbed from OS that way (but not necessarily all used). And malloc may use mmap() instead/as well and may (but probably doesn't) return memory to OS ... -- Nick Ing-Simmons http://www.ni-s.u-net.com/