死锁
1 | /** |
JVM体系结构
复制算法
标记回收算法
标记-压缩算法
GC
Boolean类型
example:
-XX:+PrintGCDetails
KV设值类型
MetaspaceSize是元空间大小
MaxTenuringThreshold是多少次之后就是老年期
jinfo
jinfo -flags 5678
可以把5678这个进程号的全部参数打印
查看JVM初始家底
java -XX:+PrintFlagsInitial
java -XX:+PrintFlagsFinal =代表默认 :=代表修改后的值
-Xms 启动时最小内存
-Xmx 最大内存
-Xss 单个线程最大栈空间
为0则为默认值,在不同系统,默认值不一样,在linux,os x,unix的64位系统中为1024k,在windows则取决于你的虚拟内存大小。
-XX:+PrintGCDetails -XX:MetaspaceSize=128m -XX:SurvivorRatio=4 -XX:NewRatio=4
-XX:+PrintGCDetails
查看gc详情
GC在青春期,FullGC在养老区
[GC (Allocation Failure) [PSYoungGen: 1752K->488K(2560K)] 1752K->664K(9728K), 0.0018961 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [PSYoungGen: 488K->496K(2560K)] 664K->716K(9728K), 0.0015663 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[Full GC (Allocation Failure) [PSYoungGen: 496K->0K(2560K)] [ParOldGen: 220K->629K(7168K)] 716K->629K(9728K), [Metaspace: 3216K->3216K(1056768K)], 0.0066899 secs] [Times: user=0.02 sys=0.00, real=0.01 secs]
[GC (Allocation Failure) [PSYoungGen: 0K->0K(2560K)] 629K->629K(9728K), 0.0004493 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[Full GC (Allocation Failure) [PSYoungGen: 0K->0K(2560K)] [ParOldGen: 629K->611K(7168K)] 629K->611K(9728K), [Metaspace: 3216K->3216K(1056768K)], 0.0068001 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
Exception in thread “main” java.lang.OutOfMemoryError: Java heap space
at tech.xixing.jvm.HelloGC.main(HelloGC.java:15)
Heap
PSYoungGen total 2560K, used 57K [0x00000000ffd00000, 0x0000000100000000, 0x0000000100000000)
eden space 2048K, 2% used [0x00000000ffd00000,0x00000000ffd0e588,0x00000000fff00000)
from space 512K, 0% used [0x00000000fff00000,0x00000000fff00000,0x00000000fff80000)
to space 512K, 0% used [0x00000000fff80000,0x00000000fff80000,0x0000000100000000)
ParOldGen total 7168K, used 611K [0x00000000ff600000, 0x00000000ffd00000, 0x00000000ffd00000)
object space 7168K, 8% used [0x00000000ff600000,0x00000000ff698f48,0x00000000ffd00000)
Metaspace used 3247K, capacity 4496K, committed 4864K, reserved 1056768K
class space used 353K, capacity 388K, committed 512K, reserved 1048576K
Process finished with exit code 1
-XX:SurvivorRatio
默认XX:SurvivorRatio=8
eden space 53248K, 8% used [0x0000000780980000,0x0000000780dab0f0,0x0000000783d80000)
from space 6144K, 0% used [0x0000000784380000,0x0000000784380000,0x0000000784980000)
to space 6144K, 0% used [0x0000000783d80000,0x0000000783d80000,0x0000000784380000)
XX:SurvivorRatio=4
PSYoungGen total 54784K, used 4404K [0x0000000780980000, 0x0000000784980000, 0x00000007c0000000)
eden space 44032K, 10% used [0x0000000780980000,0x0000000780dcd328,0x0000000783480000)
from space 10752K, 0% used [0x0000000783f00000,0x0000000783f00000,0x0000000784980000)
to space 10752K, 0% used [0x0000000783480000,0x0000000783480000,0x0000000783f00000)
-XX:NewRatio
Heap
PSYoungGen total 54784K, used 4404K [0x0000000780980000, 0x0000000784980000, 0x00000007c0000000)
eden space 44032K, 10% used [0x0000000780980000,0x0000000780dcd328,0x0000000783480000)
from space 10752K, 0% used [0x0000000783f00000,0x0000000783f00000,0x0000000784980000)
to space 10752K, 0% used [0x0000000783480000,0x0000000783480000,0x0000000783f00000)
ParOldGen total 131072K, used 0K [0x0000000701c00000, 0x0000000709c00000, 0x0000000780980000)
object space 131072K, 0% used [0x0000000701c00000,0x0000000701c00000,0x0000000709c00000)
Metaspace used 3222K, capacity 4496K, committed 4864K, reserved 1056768K
class space used 350K, capacity 388K, committed 512K, reserved 1048576K
新生代和老年代分别为54784K和131072K符合1:2
-XX:MaxTenuringThreshold
进入养老区的次数
数值必须在0-15之间