Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
I 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? –  Brian Lovett Mar 9 '13 at 19:12
    
You can look at /proc/<pid>/maps to see if libjemalloc.so is mapped. –  David Schwartz Jun 30 at 4:38

2 Answers 2

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.

…»

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.