How can I use M_MMAP_MAX?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I use M_MMAP_MAX?

Bruce Korb
I really expected this to work:

#include <malloc.h>

typedef void (malloc_init_t)   (void);

static malloc_init_t    malloc_init;

malloc_init_t * __malloc_initialize_hook = malloc_init;

static void
malloc_init(void)
{
    mallopt(M_MMAP_MAX, 0);
}

However, all the 132+892K mappings below are mmap-ed:

# pmap 4597|sed '1,/^15de/d'
15dfb000     16K rw---    [ anon ]
15e00000    132K rw---    [ anon ]
15e21000    892K -----    [ anon ]
15f00000    132K rw---    [ anon ]
15f21000    892K -----    [ anon ]
16000000    132K rw---    [ anon ]
16021000    892K -----    [ anon ]
16100000    132K rw---    [ anon ]
16121000    892K -----    [ anon ]

The last one is in current use.  The others are lost.
And, yes, I'm sure it is coming from malloc because when I use
the __malloc_hook stuff to capture larger allocations, these mappings
do not happen.  However, it hangs.  I have to go back and add some
pthread syncronization primitives, too.  Maybe that's all I need do?
Were you all having syncronization issues in glibc 2.3.2?

Thanks for your help.  Regards, Bruce
Reply | Threaded
Open this post in threaded view
|

Re: How can I use M_MMAP_MAX?

Steve Munroe
"Bruce Korb" <[hidden email]> wrote on 04/09/2008 04:14:04 PM:

> I really expected this to work:
>
> #include <malloc.h>
>
> typedef void (malloc_init_t)   (void);
>
> static malloc_init_t    malloc_init;
>
> malloc_init_t * __malloc_initialize_hook = malloc_init;
>
> static void
> malloc_init(void)
> {
>     mallopt(M_MMAP_MAX, 0);
> }
>
> However, all the 132+892K mappings below are mmap-ed:
>

All of your malloc requests are larger then the M_MMAP_THRESHOLD! And all
such allocations are mmaped.
So change your M_MMAP_THRESHOLD!

Bruce you obviously have not read the available documentation! Please do
your homework and use the #glibc for any further questions.

Steven J. Munroe
Linux on Power Toolchain Architect
IBM Corporation, Linux Technology Center