简体   繁体   中英

Spring boot application not using jemalloc

I am trying to find out a memory leak issue. I am following this article and trying to use jemalloc

The steps followed are:

export LD_PRELOAD=/usr/local/lib/libjemalloc.so
export MALLOC_CONF=prof:true,lg_prof_interval:30,lg_prof_sample:17
sudo java -jar application.jar

However there is no .heap file created. I cannot find libjemalloc.so in pmap -x result. How can I ensure that the jvm is using jemalloc? Server is an ubuntu server and the application is using spring boot.

When you run sudo , Java gets root environment which does not have your previously exported LD_PRELOAD and MALLOC_CONF .

Try

sudo LD_PRELOAD=/usr/local/lib/libjemalloc.so \
     MALLOC_CONF=prof:true,lg_prof_interval:30,lg_prof_sample:17 \
     java -jar application.jar

BTW, jemalloc is not always useful for profiling Java applications, since it cannot show Java stacks (but it is useful for preventing memory leaks caused by the standard allocator).

Try async-profiler as described in this answer .

Also check this post about Java native memory consumption.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM