Hi--

[ CC:ing Jason as the domain expert.  :-) ]

On Apr 22, 2010, at 10:01 AM, Royce Williams wrote:
> 2010/4/8 Török Edwin <edwinto...@gmail.com>:
>> On 04/08/2010 11:03 PM, Chuck Swiger wrote:
[ ... ]
>>>> # sysctl vm.max_proc_mmap
>>>> vm.max_proc_mmap: 78951
>>> 
>>> It's the number of mmap() entries which the kernel is willing to make
>>> available per process; what you display should be plenty, unless there is
>>> some kind of problem where mmap()ed files never get munmap()ed.
>> 
>> Actually thats a pretty low number if FreeBSD is using mmap() for malloc()
>> and it is not merging adjacent maps when counting this limit.
>> 
>> 78951 (maps) * 4KB (pagesize) = 308 MB
>> 
>> 308 MB is a pretty low limit for clamd, especially since the database alone
>> is ~100MB.
>> 
>> The maximum maps count on Linux is even lower, and yet everything works:
>> vm.max_map_count = 65530
>> 
>> I guess Linux merges adjacent mmap()s into a single map, and only counts
>> those.  I don't know what FreeBSD does, but if it doesn't merge the maps 
>> then that
>> max_proc_mmap limit doesn't make sense.
> 
> For anyone who picks up this thread, it's in Bugzilla here:
> 
> https://wwws.clamav.net/bugzilla/show_bug.cgi?id=1941

There may be some confusion with regard to this matter.  FreeBSD's JE malloc() 
which landed with 7.x doesn't call mmap() for every call to malloc(), or even 
for every page allocated by malloc(), but I believe will call mmap() once per 
run for sizes up to a megabyte at a time:

  http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/stdlib/malloc.c?rev=1.193

I believe it will also try fall back to using sbrk() to get DSS memory if it 
needs to.  It might be interesting for Royce to try:

   ln -s 'DmP' /etc/malloc.conf

...(or set $MALLOC_OPTIONS in clamd's environment) and see whether disabling 
mmap() allocations entirely in favor of sbrk() helps.  The "P" flag will also 
cause malloc statistics to be generated to stderr, which might also be helpful 
for debugging the issue.

Regards,
-- 
-Chuck

_______________________________________________
Help us build a comprehensive ClamAV guide: visit http://wiki.clamav.net
http://www.clamav.net/support/ml

Reply via email to