You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Qi Wang edited this page Aug 8, 2023
·
11 revisions
All of the following examples assume a standard developer environment on Unix-like machine, and something like the following shell environment variable configuration, where <path> corresponds to the --prefix=<path> setting used by the configure script, so that the shell can find jemalloc-config:
export PATH="<path>/bin:${PATH}"
There are several ways to integrate jemalloc into an application. Here are some examples, from simplest to most involved:
Use the LD_PRELOAD environment variable to inject jemalloc into the application at run time. Note that this will only work if your application does not statically link a malloc implementation.
Link jemalloc statically into the application at build time, and use it as a generic non-replaceable malloc implementation:
cc app.c -o app `jemalloc-config --libdir`/libjemalloc.a `jemalloc-config --libs`
Compile jemalloc with an API prefix (see the --with-jemalloc-prefix configure option), link with jemalloc at build time as above, but use jemalloc distinctly from the system allocator.
Once you have jemalloc integrated into your application, you can use special features in a variety of ways:
Set the /etc/malloc.conf symlink or MALLOC_CONF environment variable to tune jemalloc, e.g.