Changing memory allocator to Jemalloc Centos 6
Solution 1
It's trivial answer (actually I still don't get it how your research could have missed it):
/etc/ld.so.preload
It's documented in ld.so(8) — man 8 ld.so
: «…
/etc/ld.so.preload — File containing a whitespace separated list of ELF shared libraries to be loaded before the program.
…»
Solution 2
I found the same solution during my research. More detailed with stepwise instructions. There it is also stated that many companies switch to jemalloc (ex. Facebook) or tcmalloc (ex. Github). So you can as well try using tcmalloc (installing is quite similar) or follow the instructions and use jemalloc.
Related videos on Youtube
Brian Lovett
Updated on September 18, 2022Comments
-
Brian Lovett almost 2 years
After reading this blog post about the impact of memory allocators like jemalloc on highly threaded applications, I wanted to test things on a larger scale on some of our cluster of servers. We run sphinx, and apache using threads, and on 24 core machines.
Installing jemalloc was simple enough. We are running Centos 6, so yum install jemalloc jemalloc-devel did the trick. My question is, how do we change everything on the system over to using jemalloc instead of the default malloc built into Centos. Research pointed me at this as a potential option:
LD_PRELOAD=$LD_PRELOAD:/usr/lib64/libjemalloc.so.1
Would this be sufficient to get everything using jemalloc?
-
Brian Lovett over 11 yearsI enabled the above and restarted the services that I wanted to rest. In observing, I have seen a decrease in the Reserved memory column as well as quite a bit of movement in that column. Prior to the change the value there was typically static in size. In our case 5.4gb. Now, it fluctuates quite often, and quite quickly, but averages about 4.7gb. Since jemalloc is a faster memory allocator I "think" I can attribute my observation to the fact that it is working. If so, my next question becomes. How can I tell which memory allocator a process is using in linux?
-
David Schwartz almost 10 yearsYou can look at /proc/<pid>/maps to see if
libjemalloc.so
is mapped.
-