Re: RLIMIT_DATA and malloc(3) use of mmap(2)

From: Maxim Konovalov <maxim_at_freebsd.org>
Date: Thu, 24 Nov 2011 21:38:19 +0400 (MSK)
Hi Kostik,

On Wed, 23 Nov 2011, 11:22+0400, Maxim Konovalov wrote:

> [...]
> > Anyway, the patch needs testers before I will push it forward.
> >
> [igor's email was corrected]
>
> We will test it in out environment and let you know.
>
It seems I don't understand how it works.

Here is a test program: http://maxim.int.ru/stuff/malloc_test.c.txt

It allocates successfully 64x1MB chunks by malloc(), reallocf() and
realloc() with the following command line:

MALLOC_OPTIONS=JM limits -d 10m ./malloc_test

When we add L flag to the MALLOC_OPTIONS it starts to work strange:

It allocates 64MB via malloc() but fails to allocate more than 3MB by
realloc() and reallocf().

More funny, the result varies from time to time:

$ MALLOC_OPTIONS=JML limits -d 10m ./malloc_test | head
RLIMIT_DATA: rlim_cur is 10485760, rlim_max is 10485760
1th allocation failed
2th allocation failed
3th allocation failed
4th allocation failed
5th allocation failed
6th allocation failed
7th allocation failed
8th allocation failed
9th allocation failed
$ MALLOC_OPTIONS=JML limits -d 10m ./malloc_test | head
RLIMIT_DATA: rlim_cur is 10485760, rlim_max is 10485760
1048576 bytes successfuly allocated
2097152 bytes successfuly allocated
3145728 bytes successfuly allocated
4194304 bytes successfuly allocated
5242880 bytes successfuly allocated
6291456 bytes successfuly allocated
7340032 bytes successfuly allocated
8388608 bytes successfuly allocated
9437184 bytes successfuly allocated
$ MALLOC_OPTIONS=JML limits -d 10m ./malloc_test | head
RLIMIT_DATA: rlim_cur is 10485760, rlim_max is 10485760
1th allocation failed
2th allocation failed
3th allocation failed
4th allocation failed
5th allocation failed
6th allocation failed
7th allocation failed
8th allocation failed
9th allocation failed

It's today -current with your patch.

-- 
Maxim Konovalov
Received on Thu Nov 24 2011 - 16:38:22 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:21 UTC