Using MariaDB with TCMalloc or jemalloc

You are viewing an old version of this article. View the current version here.

TCMalloc is a malloc replacement library optimized for multi-threaded usage. It also features a built-in heap debugger and profiler. You can build MariaDB with it or LD_PRELOAD it.

To build MariaDB 5.5 with TCMalloc, you need to use the following command

cmake -DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'  -DWITH_SAFEMALLOC=OFF

Many other malloc replacement libraries (as well as heap debuggers and profilers) can be used with MariaDB in a similar fashion.

You can also start a standard MariaDB server with TCmalloc with:

/usr/sbin/mysqld_safe --malloc-lib=tcmalloc

or alternative just set LD_PRELOAD to point to the to be used malloc library:

export LD_PRELOAD=/path/to/library

The above procedure also works with jemalloc. Just replace tcmalloc with jemalloc in the above commands.

See Also

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.