Shachar Shemesh wrote:

Re Choo's comment about memory available through "malloc" working for him - malloc uses "brk(2)" to allocate memory as long as it possibly can.

Actually, that is not a completely accurate description of malloc() behavior even in glibc:

Indeed, malloc manages the heap, which it extends via brk() if needed, for allocations smaller then a certain threshold (used to be 128k, nowdays it is dynamically computed) and for allocation bigger then the threshold, it indeed uses mmap().

However, the reason for for this behavior is memory usage, not ability - allocating big chunks (for some definition of big) from the heap can render the logic that tries to claim unused heap space non efficient due to fragmentation, for example if a big chunk allocation (3.5Mb) is followed by a small one (16 bytes) and then the bug chunk is released - glibc will not be able to reclaim the extra heap space with brk(), because of the small allocation at the end.

These have been 60 seconds on optimizations of the malloc  arena :-)

Gilad

--
Gilad Ben-Yossef Chief Coffee Drinker

Codefidence Ltd.
The code is free, your time isn't.(TM)

Web:    http://codefidence.com
Email:  [EMAIL PROTECTED]
Office: +972-8-9316883 ext. 201
Fax:    +972-8-9316885
Mobile: +972-52-8260388


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to