Custom allocator on top of jemalloc

SNL snl20465 at
Tue Jan 20 05:17:07 PST 2015


Here is what I am doing currently:

1. I am trying to carve out 10 MB memory area at the higher end of process
address space using mmap (MAP_FIXED..).

2. I created a new arena using arenas.extend mallctl

3. I am using mallocx/dallocx with MALLOCX_ARENA(arena) as documented.

The issue is how do I connect the arena to mmaped memory chunk ? I see that
new arena never gets initialized and all allocations continue to happen
from arena 0x0.
I thought thread.arena mallctl will connect the arena to mmapped chunk but
it just creates a thread <-> arena mapping.

I looked at the sources to see if there is any other mallctl to create this
association but there does not seem to be any, what am I missing here ?

And older sample program I found on this mailing list, uses following
mallctl which is not supported in jemalloc 3.6.

snprintf(path, sizeof(path), "arena.%u.chunk.alloc", _arena);
  ret = __svm_mallctl(path, (void*)&_chunk_alloc, &sz,
(void*)&_chunk_alloc, sizeof(void *));
  assert (ret == 0);

snprintf(path, sizeof(path), "arena.%u.chunk.dalloc", _arena);
  ret = __svm_mallctl(path, (void*)&_chunk_dalloc, &sz,
(void*)&_chunk_dalloc, sizeof(void *));
  assert (ret == 0);

This basically is asking jemalloc to callback user defined functions, is
this functionality still available in jemalloc ? Any inputs will be
helpful. Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the jemalloc-discuss mailing list