Idea运行代码的时候带上VM参数用来分析堆外内存使用情况
2019-04-28 本文已影响0人
JAVA弑云
我这边由于想查看JVM堆外内存的使用情况,需要设置如下参数:
-XX:NativeMemoryTracking=summary
-XX:+UnlockDiagnosticVMOptions
-XX:+PrintNMTStatistics
首先编写简单的HelloWorld代码:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("HelloWolrd");
}
}
点这个Edit ConFigurations
image
在红框处就可以进行编辑你想配置的参数了
image.png
然后点击运行就好了,如果运行报错,应该就是你的vm参数可能写错了,Console会有详细的错误输出以及相关的提示
以下是我的运行结果:
HelloWolrd
Native Memory Tracking:
Total: reserved=3514083KB, committed=242639KB
- Java Heap (reserved=2097152KB, committed=131072KB)
(mmap: reserved=2097152KB, committed=131072KB)
- Class (reserved=1062015KB, committed=10111KB)
(classes #531)
(malloc=5247KB #176)
(mmap: reserved=1056768KB, committed=4864KB)
- Thread (reserved=15424KB, committed=15424KB)
(thread #15)
(stack: reserved=15360KB, committed=15360KB)
(malloc=46KB #81)
(arena=19KB #31)
- Code (reserved=249639KB, committed=2575KB)
(malloc=39KB #332)
(mmap: reserved=249600KB, committed=2536KB)
- GC (reserved=82395KB, committed=75999KB)
(malloc=5771KB #119)
(mmap: reserved=76624KB, committed=70228KB)
- Compiler (reserved=132KB, committed=132KB)
(malloc=2KB #24)
(arena=131KB #3)
- Internal (reserved=5369KB, committed=5369KB)
(malloc=5337KB #1527)
(mmap: reserved=32KB, committed=32KB)
- Symbol (reserved=1512KB, committed=1512KB)
(malloc=960KB #160)
(arena=552KB #1)
- Native Memory Tracking (reserved=43KB, committed=43KB)
(malloc=3KB #40)
(tracking overhead=39KB)
- Arena Chunk (reserved=400KB, committed=400KB)
(malloc=400KB)