1

I am trying to diagnose memory issues for a java process running in Docker under Kubernetes.

Java version is Java 8 (1.8.0):

root@myHost:/# java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-2~deb9u1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)

I see much of the online discussion and suggestions and questions on SO involve the use of Native Memory Tracking.

If I enable NMT, what negative impacts can I expect to the performance or memory usage?

Is it fine/permissible/recommended to enable NMT in Production at all times at "detail" level:

-XX:NativeMemoryTracking=detail
MattG
  • 5,589
  • 5
  • 36
  • 52

1 Answers1

1

From Oracle Native Memory Tracking for Java 8 documentation:

Get detail data: To get a more detailed view of native memory usage, start the JVM with command line option: -XX:NativeMemoryTracking=detail. This will track exactly what methods allocate the most memory. Enabling NMT will result in 5-10 percent JVM performance drop and memory usage for NMT adds 2 words to all malloc memory as malloc header. NMT memory usage is also tracked by NMT.

Once NMT is enabled the jcmd output for VM.native_memory will actually record what looks like the memory allocation overhead due to having NMT enabled:

#jcmd 25 VM.native_memory
25:

Native Memory Tracking:

Total: reserved=2724013KB, committed=1526785KB
-                 Java Heap (reserved=1048576KB, committed=1048576KB)
                        (mmap: reserved=1048576KB, committed=1048576KB)
...

    Native Memory Tracking (reserved=6004KB, committed=6004KB)
                        (malloc=384KB #6040)
                        (tracking overhead=5621KB)
MattG
  • 5,589
  • 5
  • 36
  • 52