Question regarding jemalloc and JVM
jasone at canonware.com
Sat Mar 24 21:00:17 PDT 2012
On Mar 24, 2012, at 11:46 AM, Jason Evans wrote:
> On Mar 23, 2012, at 4:21 PM, Vijay wrote:
>> Is there any reason i should not be using LD_PRELOAD to force JVM use jemalloc instead of native gcc malloc?
>> Background: This is for Apache-Cassandra we do off-heap cache where we explicitly call malloc and free and by using jemalloc we see a fair amount of space savings and was wondering if there is anything which we have to consider before using it.
> LD_PRELOAD'ing jemalloc should be okay as long as the JVM doesn't statically link a different malloc implementation. I expect that if it isn't safe, you'll experience crashes quite early on, so give it a try and see what happens.
I was just looking through some of my notes and noticed an issue that may be relevant here. jemalloc has a configure option called lazy-lock that has apparently caused problems in some Java use cases. Java was using dlopen() to load a library that was dynamically linked with jemalloc, so jemalloc came along too late to intercept pthread_create() calls and turn on locking. I don't think your use case will hit the same issue, but beware of dlopen() anywhere in the mix.
More information about the jemalloc-discuss