trace 跟踪参数
-verbose:gc
-XX:+PrintGC 打印gc
-XX:+PrintGCDetails 打印gc的详细信息
Heap
PSYoungGen total 76288K, used 5243K [0x000000076b380000, 0x0000000770880000, 0x00000007c0000000)
eden space 65536K, 8% used [0x000000076b380000,0x000000076b89ed38,0x000000076f380000)
from space 10752K, 0% used [0x000000076fe00000,0x000000076fe00000,0x0000000770880000)
to space 10752K, 0% used [0x000000076f380000,0x000000076f380000,0x000000076fe00000)
ParOldGen total 175104K, used 0K [0x00000006c1a00000, 0x00000006cc500000, 0x000000076b380000)
object space 175104K, 0% used [0x00000006c1a00000,0x00000006c1a00000,0x00000006cc500000)
Metaspace used 2874K, capacity 4486K, committed 4864K, reserved 1056768K
class space used 308K, capacity 386K, committed 512K, reserved 1048576K
-XX:+PrintGCTimeStamps 打印gc发生的时间戳
-Xloggc:log/gc.log 指定log文件位置
-XX:+PrintHeapAtGC 查看gc前后堆的大小
-XX:+TraceClassLoading 监控类的加载
-XX:+PrintClassHistogram 按下ctrl+break 打印类的信息
-Xmx -Xms
指定最大推和最小堆
比如 -Xmx20m -Xms5M
-Xmn 设置新生代的大小
-XX:SurvivorRatio
设置两个Survivor区(s0,s1)和eden的比
8表示 两个survivor:eden=2:8 ,即一个survivor占年轻代的1/10
-XX:NewRatio
新生代(eden+2*s)和老年代(不包含永久区)的比值
新生代:老年代 = 1:4 即年轻代占堆的1/5
-XX:+HeapDumpOnOutOfMemoryError oom 时导出oom堆到文件
-XX:+HeapDumpPath 导出oom的路径
-Xmx20m -Xms5m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=d:/log.txt
-XX:OnOutOfMemoryError
在发生内存不够的时候执行一个脚本
-XX:OnOutOfMemoryError=D:/tools/jdk1.7_40/bin/printstack.bat %p
当程序OOM时,在D:/a.txt中将会生成线程的dump
注:
根据事件调整新生代和幸存代的大小
官方推荐新生代占堆的3/8
幸存代占新生代的1/10
在oom 时,记得dump出堆,确保可以排查现场问题
永久区配置参数
-XX:PermSize -XX:MaxPermSize
设置永久区的初始空间和最大空间
一个系统可以容纳多少个类型
-Xss 栈大小
通常只有几百K
决定了函数调用的深度
每个线程都有独立的栈空间
局部变量、参数 分配在栈上
-verbose:gc
-XX:+PrintGC 打印gc
-XX:+PrintGCDetails 打印gc的详细信息
Heap
PSYoungGen total 76288K, used 5243K [0x000000076b380000, 0x0000000770880000, 0x00000007c0000000)
eden space 65536K, 8% used [0x000000076b380000,0x000000076b89ed38,0x000000076f380000)
from space 10752K, 0% used [0x000000076fe00000,0x000000076fe00000,0x0000000770880000)
to space 10752K, 0% used [0x000000076f380000,0x000000076f380000,0x000000076fe00000)
ParOldGen total 175104K, used 0K [0x00000006c1a00000, 0x00000006cc500000, 0x000000076b380000)
object space 175104K, 0% used [0x00000006c1a00000,0x00000006c1a00000,0x00000006cc500000)
Metaspace used 2874K, capacity 4486K, committed 4864K, reserved 1056768K
class space used 308K, capacity 386K, committed 512K, reserved 1048576K
-XX:+PrintGCTimeStamps 打印gc发生的时间戳
-Xloggc:log/gc.log 指定log文件位置
-XX:+PrintHeapAtGC 查看gc前后堆的大小
-XX:+TraceClassLoading 监控类的加载
-XX:+PrintClassHistogram 按下ctrl+break 打印类的信息
-Xmx -Xms
指定最大推和最小堆
比如 -Xmx20m -Xms5M
-Xmn 设置新生代的大小
-XX:SurvivorRatio
设置两个Survivor区(s0,s1)和eden的比
8表示 两个survivor:eden=2:8 ,即一个survivor占年轻代的1/10
-XX:NewRatio
新生代(eden+2*s)和老年代(不包含永久区)的比值
新生代:老年代 = 1:4 即年轻代占堆的1/5
-XX:+HeapDumpOnOutOfMemoryError oom 时导出oom堆到文件
-XX:+HeapDumpPath 导出oom的路径
-Xmx20m -Xms5m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=d:/log.txt
-XX:OnOutOfMemoryError
在发生内存不够的时候执行一个脚本
-XX:OnOutOfMemoryError=D:/tools/jdk1.7_40/bin/printstack.bat %p
当程序OOM时,在D:/a.txt中将会生成线程的dump
注:
根据事件调整新生代和幸存代的大小
官方推荐新生代占堆的3/8
幸存代占新生代的1/10
在oom 时,记得dump出堆,确保可以排查现场问题
永久区配置参数
-XX:PermSize -XX:MaxPermSize
设置永久区的初始空间和最大空间
一个系统可以容纳多少个类型
-Xss 栈大小
通常只有几百K
决定了函数调用的深度
每个线程都有独立的栈空间
局部变量、参数 分配在栈上