strange memory leak (in ldb?)

Angelos Oikonomopoulos angelos.oikonomopoulos at fp-commerce.de
Fri Nov 5 05:27:27 MDT 2010


On 11/05/2010 09:59 AM, Volker Lendecke wrote:
> On Fri, Nov 05, 2010 at 07:00:01AM +0100, Stefan (metze) Metzmacher wrote:
>> Hi Kamen,
>>
>> it seems you're right. I have a standalone tool to demonstrate it.
>>
>> http://gitweb.samba.org/?p=metze/misc/junkcode.git;a=blob;f=malloc-reclaim/malloc-reclaim.c
>>
>> I wonder if there's a way to avoid that memory fragmentation.
>> Also the heap is still there at the last mybreak().
>
> The most likely fix for this would be to go with
> http://samba.org/~tridge/junkcode/alloc_mmap/

I don't think using an allocator that "releases memory back to the OS as 
much as possible" is a good idea for normal operation. Ideally one would 
want to treat allocations for such operations differently e.g. by 
dynamically changing the malloc() parameters (via mallopt()) so that the 
memory can be freed after the operation is over. Unfortunately, other 
malloc implementations (e.g. most BSD ones) don't allow you to change 
the parameters dynamically. I'm not yet familiar enough with samba 
internals to know if there's a better way :)

Aggelos


More information about the samba-technical mailing list