Jemalloc:Java 本机内存分析显示 100% je_prof_backtrace

Jemalloc: Java Native Memory profiling shows 100% je_prof_backtrace

我们有一个多线程生产 Java 应用程序。我们正在尝试检查 post.

中提到的本机内存使用情况

但是在转储中我看到 je_prof_backtrace

占用了 100% 的内存
ubuntu@platform1:/tmp/jemalloc_dump$ /home/ubuntu/jemalloc/bin/jeprof --show_bytes `which java` /tmp/jemalloc_dump/tsdb.62634.6454.i6454.heap
Using local file /usr/bin/java.
Using local file /tmp/jemalloc_dump/tsdb.62634.6454.i6454.heap
Welcome to jeprof!  For help, type 'help'.
(jeprof) top
Total: 815965512 B
815965512 100.0% 100.0% 815965512 100.0% je_prof_backtrace
       0   0.0% 100.0% 268451840  32.9% 0x00007f1338bd83a5
       0   0.0% 100.0% 279057735  34.2% 0x00007f13390d615a
       0   0.0% 100.0% 268455936  32.9% 0x00007f133918adda
       0   0.0% 100.0% 268455936  32.9% AllocateHeap
       0   0.0% 100.0% 268455936  32.9% JVM_MonitorWait
       0   0.0% 100.0% 268451840  32.9% Java_java_util_zip_Inflater_inflateBytesBytes
       0   0.0% 100.0% 268455936  32.9% ObjectSynchronizer::inflate
       0   0.0% 100.0% 268455936  32.9% ObjectSynchronizer::omAlloc
       0   0.0% 100.0% 268455936  32.9% ObjectSynchronizer::wait```

如果我使用 text

,输出如下所示
(jeprof) text
Total: 815965512 B
815965512 100.0% 100.0% 815965512 100.0% je_prof_backtrace
       0   0.0% 100.0% 268451840  32.9% 0x00007f1338bd83a5
       0   0.0% 100.0% 279057735  34.2% 0x00007f13390d615a
       0   0.0% 100.0% 268455936  32.9% 0x00007f133918adda
       0   0.0% 100.0% 268455936  32.9% AllocateHeap
       0   0.0% 100.0% 268455936  32.9% JVM_MonitorWait
       0   0.0% 100.0% 268451840  32.9% Java_java_util_zip_Inflater_inflateBytesBytes
       0   0.0% 100.0% 268455936  32.9% ObjectSynchronizer::inflate
       0   0.0% 100.0% 268455936  32.9% ObjectSynchronizer::omAlloc
       0   0.0% 100.0% 268455936  32.9% ObjectSynchronizer::wait

遵循的步骤。

  1. 已从 here 下载 jemalloc 5.2.1 发布标签。
  2. ./autogen.sh --enable-prof inside jmalloc tar in untared.
  3. 所在目录
  4. make

应用程序tar使用以下选项

export JEMALLOC_PATH=/home/ubuntu/jemalloc
export MALLOC_CONF=prof:true,lg_prof_interval:21,lg_prof_sample:28,prof_prefix:/tmp/jemalloc_dump/tsdb
LD_PRELOAD=${JEMALLOC_PATH}/lib/libjemalloc.so.2 \
java ...

我是 jemalloc 的新手。有人可以提出可能出了什么问题吗?

ubuntu@platform1:/tmp/jemalloc_dump$ java -version
openjdk version "11.0.11" 2021-04-20 LTS
OpenJDK Runtime Environment Zulu11.48+22-SA (build 11.0.11+9-LTS)
OpenJDK 64-Bit Server VM Zulu11.48+22-SA (build 11.0.11+9-LTS, mixed mode)

尝试使用以下标志进行配置:

./configure --enable-prof --enable-stats --enable-debug --enable-fill

github 中也对此进行了讨论。发布相关回复

Quoting Jason from the original thread:

This is usually caused by the backtracing facility failing to do anything beyond reporting the caller's return instruction pointer. You may have better luck if you use libunwind, but unfortunately I've seen all the supported backtracing mechanisms fail under various conditions.

In other words, if you haven't tried libunwind, give that a try. The reported issue happens when the stack unwinder cannot walk the stack, in which case jemalloc / jeprof doesn't have any backtrace data to report.

Closing because nothing actionable from the jemalloc side.