Example of using jemalloc to manage a given memory space?

Bill O'Hara billtohara at gmail.com
Sun Jun 12 14:22:11 PDT 2016


On Wed, Jun 8, 2016 at 5:26 PM, Jason Evans <jasone at canonware.com> wrote:

> On Jun 4, 2016, at 3:22 PM, Bill O'Hara <billtohara at gmail.com> wrote:
> > I see various hints that it's possible to use jemalloc to manage a given
> memory space. That is, given a pointer to say 16GB of byte addressable
> memory, use jemalloc to manage it as a heap.
> >
> > 1) Can someone point me in the direction of a simple example, or hints
> on how to configure jemalloc to do this?
>
> Here's the relevant documentation:
>
>
> http://www.canonware.com/download/jemalloc/jemalloc-latest/doc/jemalloc.html#arena.i.chunk_hooks
>
> Here's a test case that gives a basic example of how to use the chunk
> hooks API:
>
>
> https://github.com/jemalloc/jemalloc/blob/master/test/integration/chunk.c



Thank you Jason, after some fiddling, I got my existing code rebased on top
of a jemalloc managed arena. Perf looks great.

Thanks also for the clear answer on the second part.

Bill



> > 2) Further -- is it possible to get jemalloc to put it's own data
> structures entirely within the given 16GB space, so that if the process
> restarts that the heap can be reattached?
>
> No, there are lots of places where jemalloc uses static data, and it's
> generally important to performance to do so.  As of 4.2.0,
> application-created arenas (see
> http://www.canonware.com/download/jemalloc/jemalloc-latest/doc/jemalloc.html#arenas.extend)
> put all their metadata in one of the automatically multiplexed arenas so
> that it's possible to discard the contents of an arena with a single call (
> http://www.canonware.com/download/jemalloc/jemalloc-latest/doc/jemalloc.html#arena.i.reset),
> which is sort of the opposite of what you want.
>
> Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jemalloc.net/mailman/jemalloc-discuss/attachments/20160612/3c09366f/attachment.html>


More information about the jemalloc-discuss mailing list