默认该功能是禁用的,因为会损失5-10%的性能
开启命令
-XX:NativeMemoryTracking=detail
打印命令
jcmd 45064 VM.native_memory summary scale=MB > NativeMemoryTracking.log
具体的日志信息
➜ ~
➜ ~ jcmd 45064 VM.native_memory summary scale=MB
45064:
Native Memory Tracking:
(Omitting categories weighting less than 1MB)
Total: reserved=5676MB, committed=654MB
malloc: 58MB #363115
mmap: reserved=5618MB, committed=596MB
- Java Heap (reserved=4096MB, committed=200MB)
(mmap: reserved=4096MB, committed=200MB)
- Class (reserved=1025MB, committed=11MB)
(classes #16551)
( instance classes #15574, array classes #977)
(malloc=1MB #44456)
(mmap: reserved=1024MB, committed=10MB)
( Metadata: )
( reserved=64MB, committed=63MB)
( used=62MB)
( waste=1MB =0.90%)
( Class space:)
( reserved=1024MB, committed=10MB)
( used=9MB)
( waste=0MB =3.79%)
- Thread (reserved=258MB, committed=258MB)
(thread #129)
(stack: reserved=258MB, committed=258MB)
- Code (reserved=50MB, committed=19MB)
(malloc=2MB #10874)
(mmap: reserved=48MB, committed=17MB)
- GC (reserved=130MB, committed=54MB)
(malloc=17MB #9999)
(mmap: reserved=112MB, committed=36MB)
- Internal (reserved=1MB, committed=1MB)
(malloc=1MB #18262)
- Symbol (reserved=26MB, committed=26MB)
(malloc=22MB #218120)
(arena=4MB #1)
- Native Memory Tracking (reserved=6MB, committed=6MB)
(tracking overhead=6MB)
- Shared class space (reserved=16MB, committed=13MB, readonly=0MB)
(mmap: reserved=16MB, committed=13MB)
- Synchronization (reserved=3MB, committed=3MB)
(malloc=3MB #50578)
- Metaspace (reserved=64MB, committed=63MB)
(mmap: reserved=64MB, committed=63MB)
堆外内存异常问题排查