728x90
특정 Java 어플리케이션의 Native 메모리 사용을 추적하기 위해서는 JAVA 어플리케이션 실행 시 다음과 같은 옵션을 추가해서 기동해줘야 한다.
-XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -XX:+PrintNMTStatistics |
다음은 해당 Java 어플리케이션의 PID를 얻기 위해 사용할 수 있는 방법이다.
[weblogic@localhost jh_domain]$ /usr/java/jdk1.8.0_311/bin/jps -l 4985 sun.tools.jps.Jps 4540 weblogic.Server |
다음은 Native memory tracking을 위해 jcmd를 사용하는 방법이다.
[weblogic@localhost jh_domain]$ /usr/java/jdk1.8.0_311/bin/jcmd 4540 VM.native_memory 4540: Native Memory Tracking: Total: reserved=2731913KB, committed=1468189KB - Java Heap (reserved=1048576KB, committed=1048576KB) (mmap: reserved=1048576KB, committed=1048576KB) - Class (reserved=1167413KB, committed=133301KB) (classes #21320) (malloc=2101KB #30624) (mmap: reserved=1165312KB, committed=131200KB) - Thread (reserved=139577KB, committed=139577KB) (thread #137) (stack: reserved=138968KB, committed=138968KB) (malloc=449KB #684) (arena=160KB #271) - Code (reserved=254117KB, committed=26553KB) (malloc=4517KB #7812) (mmap: reserved=249600KB, committed=22036KB) - GC (reserved=77794KB, committed=77794KB) (malloc=6114KB #13898) (mmap: reserved=71680KB, committed=71680KB) - Compiler (reserved=268KB, committed=268KB) (malloc=137KB #807) (arena=131KB #5) - Internal (reserved=5488KB, committed=5488KB) (malloc=5456KB #29711) (mmap: reserved=32KB, committed=32KB) - Symbol (reserved=29847KB, committed=29847KB) (malloc=27058KB #328827) (arena=2789KB #1) - Native Memory Tracking (reserved=6476KB, committed=6476KB) (malloc=23KB #267) (tracking overhead=6453KB) - Arena Chunk (reserved=307KB, committed=307KB) (malloc=307KB) - Unknown (reserved=2048KB, committed=0KB) (mmap: reserved=2048KB, committed=0KB) |
가령 Thread의 경우 현재 139577KB이 committed 됐으며, 137개의 thread가 실행중이라고 볼 수 있다.
(* reserved는 가용할 수 있는 메모리 영역, committed는 실제 사용 중인 메모리 영역)
또한 위 native 값들은 peak time일때의 수치와 평상시의 수치에 대한 비교가 중요하다.
peak time일 때 얼마나 값들이 사용되는지에 따라 tuning point가 될 수 있기 때문.
이를 위해서는 다음과 같은 방법을 사용할 수 있다.
jcmd <PID> VM.native_memory baseline => baseline 시점 설정 jcmd <PID> VM.native_memory summary.diff => baseline 시점 기준 얼마나 달라졌는지에 대한 수치 (+/-로 표기) 데이터화 |
728x90
'JAVA > JAVA' 카테고리의 다른 글
JAVA process의 CPU 사용량 패턴 분석 (0) | 2024.01.08 |
---|---|
HashMap (0) | 2022.12.26 |
java/lang/object (1) | 2022.12.26 |
JVM memory 모니터링 (1) | 2022.09.23 |
JMX (0) | 2022.06.14 |