JVM覚書

Java仮想マシン

GCログ設定

-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -Xloggc:./gc.log
  • -XX:+ PrintGC GCログ出力
  • -XX:+ PrintGCDetails出力GCのログを詳細に説明
  • -XX:(基準時間の形で)+ PrintGCTimeStamps GC出力タイムスタンプ
  • -XX:+ PrintGCDateStamps GC出力タイムスタンプ(日時の形で、例えば2013-05-04T21として:53:59.234 + 0800)
  • -XX:PrintHeapAtGC前との間に+ GCは情報のヒープをプリントアウト
  • -Xloggc:./ログファイルの出力パスgc.log
Java HotSpot(TM) 64-Bit Server VM (25.121-b13) for windows-amd64 JRE (1.8.0_121-b13), built on Dec 12 2016 18:21:36 by "java_re" with MS VC++ 10.0 (VS2010)
Memory: 4k page, physical 16599008k(3716028k free), swap 27331352k(3936160k free)
CommandLine flags: -XX:InitialHeapSize=20971520 -XX:MaxHeapSize=20971520 -XX:MaxNewSize=10485760 -XX:NewSize=10485760 -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -XX:SurvivorRatio=8 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC 
{Heap before GC invocations=1 (full 0):
 PSYoungGen      total 9216K, used 6307K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)
  eden space 8192K, 76% used [0x00000000ff600000,0x00000000ffc28ce8,0x00000000ffe00000)
  from space 1024K, 0% used [0x00000000fff00000,0x00000000fff00000,0x0000000100000000)
  to   space 1024K, 0% used [0x00000000ffe00000,0x00000000ffe00000,0x00000000fff00000)
 ParOldGen       total 10240K, used 0K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)
  object space 10240K, 0% used [0x00000000fec00000,0x00000000fec00000,0x00000000ff600000)
 Metaspace       used 3477K, capacity 4496K, committed 4864K, reserved 1056768K
  class space    used 384K, capacity 388K, committed 512K, reserved 1048576K
2019-11-28T09:53:34.265+0800: 0.123: [GC (Allocation Failure) [PSYoungGen: 6307K->776K(9216K)] 6307K->4880K(19456K), 0.0022355 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
Heap after GC invocations=1 (full 0):
 PSYoungGen      total 9216K, used 776K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)
  eden space 8192K, 0% used [0x00000000ff600000,0x00000000ff600000,0x00000000ffe00000)
  from space 1024K, 75% used [0x00000000ffe00000,0x00000000ffec2020,0x00000000fff00000)
  to   space 1024K, 0% used [0x00000000fff00000,0x00000000fff00000,0x0000000100000000)
 ParOldGen       total 10240K, used 4104K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)
  object space 10240K, 40% used [0x00000000fec00000,0x00000000ff002020,0x00000000ff600000)
 Metaspace       used 3477K, capacity 4496K, committed 4864K, reserved 1056768K
  class space    used 384K, capacity 388K, committed 512K, reserved 1048576K
}
Heap
 PSYoungGen      total 9216K, used 7241K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)
  eden space 8192K, 78% used [0x00000000ff600000,0x00000000ffc50650,0x00000000ffe00000)
  from space 1024K, 75% used [0x00000000ffe00000,0x00000000ffec2020,0x00000000fff00000)
  to   space 1024K, 0% used [0x00000000fff00000,0x00000000fff00000,0x0000000100000000)
 ParOldGen       total 10240K, used 4104K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)
  object space 10240K, 40% used [0x00000000fec00000,0x00000000ff002020,0x00000000ff600000)
 Metaspace       used 3499K, capacity 4498K, committed 4864K, reserved 1056768K
  class space    used 387K, capacity 390K, committed 512K, reserved 1048576K

一般的なJVMのメモリ設定

参考:OracleのJavase8ドク

-Xms1024M -Xmx1024M -Xmn512M -Xss2M -XX:SurvivorRatio=8 -XX:MaxMetaspaceSize=256M
  • -Xms1024mスペースの制約が最小ヒープを設定し、メモリの占有サイズは、ときに、プログラムが開始よりも一般的に大きいです。
  • -Xmx1024Mヒープ上限を適用するために設けられた空間、および-XX:MaxHeapSize同じ機能、および一般的な-Xms -Xmxセット同じ値に、
  • 「若い世代」の初期値とヒープ領域-Xmn512Mの最大サイズは、セットが小さすぎる場合、頻繁にマイナーGC原因は、セットが大きすぎる場合は、GCを介して単一の時間でフルGCの結果に蓄積します長い、若い世代のサイズの正式勧告は、ヒープの4分の1に半分です。
  • 最大-Xss2mは、仮想マシンのスタック(スレッド・スタック)、機能や-XXを設定:ThreadStackSizeは同じことを、一般的に1MBのデフォルトについて
  • -XX:SurvivorRatio = 8に配置された比率エデン領域及び生存領域は、デフォルト設定はEden80%、From_Survivor10%、To_Survivor10%、8
  • -XX:MaxMetaspaceSize最大要素間隔が直接メモリ256Mに設けられ=;、空間ホストを残りどのくらいの、デフォルトのに限定されない多くのスペースに適用することができます。

おすすめ

転載: www.cnblogs.com/IC1101/p/11945000.html