Is it safe to mix jemalloc with glibc malloc?

Justin Lebar justin.lebar at
Tue Feb 28 06:29:31 PST 2012

> 1. compile jemalloc with "je_" prefix and with "--enable-swap",
> 2. in my application:
> ...
> void *big = je_malloc(10000);
> void *small = malloc(10);
> ...
> je_free(big);
> free(small);

Yes, this is safe.

> There are plenty of small objects which will be freed soon, so I want to use
> the real
> memory for these temp objects to improve performance.

But I seriously doubt you're going to see a performance improvement by
doing this.  IME, jemalloc is much faster than glibc malloc, for all
allocation sizes.


More information about the jemalloc-discuss mailing list