[PATCH 1/2] Move zone registration to zone.c
Mike Hommey
mh+jemalloc at glandium.org
Tue Mar 27 05:46:14 PDT 2012
On Tue, Mar 27, 2012 at 02:20:12PM +0200, Mike Hommey wrote:
> @@ -743,8 +723,8 @@ void
> jemalloc_darwin_init(void)
> {
>
> - if (malloc_init_hard())
> - abort();
> + if (!malloc_init_hard())
> + register_zone();
> }
> #endif
Please note that I first attempted to move this function too, and do
lazy initialization of jemalloc, but that ends up in a dead lock because
pthread_atfork calls malloc.
A possible solution is to force malloc_init_hard before registration,
which means making the function non-static.
Another is to call one of the allocation functions and free the
allocated memory. That seemed wasteful.
Another is to call one of the allocation functions and make sure it's
doing nothing besides initialization. For example, calling
je_calloc(0x1000, 0x1000) on 32-bits platform would trigger
initialization but would allocate nothing (because 0x1000 * 0x1000 ==
0). That seemed too hackish.
Mike
More information about the jemalloc-discuss
mailing list