5

現在、興味深い「java.lang.OutOfMemoryError: Metaspace」の問題を調査しています。Metaspace の使用量が最大 Metaspace サイズ (1GB) よりもはるかに少ないため、「興味深い」と思う理由。ヒープと GC の構成は次のとおりです。

OS: Windows Server 2012 R2
Java HotSpot(TM) 64-Bit Server VM (25.92-b14) for windows-amd64 JRE (1.8.0_92-b14), built on Mar 31 2016 21:03:04 by "java_re" with MS VC++ 10.0 (VS2010)
Memory: 4k page, physical 29359668k(24768956k free), swap 37748276k(29744220k free)
CommandLine flags: -XX:CompressedClassSpaceSize=314572800 -XX:GCLogFileSize=104857600 -XX:+HeapDumpOnOutOfMemoryError -XX:InitialHeapSize=4294967296 -XX:InitiatingHeapOccupancyPercent=45 -XX:+ManagementServer -XX:MaxHeapSize=6442450944 -XX:MaxMetaspaceFreeRatio=80 -XX:MaxMetaspaceSize=1073741824 -XX:MetaspaceSize=536870912 -XX:MinMetaspaceFreeRatio=50 -XX:NumberOfGCLogFiles=20  -XX:+PrintAdaptiveSizePolicy -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseGCLogFileRotation -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC -XX:+UseParallelOldGC 

以下は、JVM がクラッシュする前の最後の 6 つの GC イベントです。

PSAdaptiveSizePolicy::compute_eden_space_size: costs minor_time: 0.001800 major_cost: 0.000613 mutator_cost: 0.997587 throughput_goal: 0.990000 live_space: 1064594816 free_space: 2587885568 old_eden_size: 1486356480 desired_eden_size: 1443889152
PSAdaptiveSizePolicy::compute_old_gen_free_space: costs minor_time: 0.001800 major_cost: 0.000613 mutator_cost: 0.997587 throughput_goal: 0.990000 live_space: 1095533824 free_space: 2545418240 old_promo_size: 1101529088 desired_promo_size: 1078460416
AdaptiveSizePolicy::old generation size: collection: 1121 (2867855360) -> (2863661056) 
AdaptiveSizeStop: collection: 1121 
[PSYoungGen: 4825K->0K(1456640K)] [ParOldGen: 2799035K->902778K(2796544K)] 2803860K->902778K(4253184K), [Metaspace: 330658K->329502K(614400K)], 1.0547274 secs] [Times: user=3.03 sys=0.00, real=1.06 secs] 
2020-02-05T07:47:01.085-0500: 23601.918: [GC (Allocation Failure) AdaptiveSizePolicy::update_averages:  survived: 55971960  promoted: 8192  overflow: false
AdaptiveSizeStart: 23601.976 collection: 1122 
  avg_survived_padded_avg: 107655896.000000  avg_promoted_padded_avg: 77367808.000000  avg_pretenured_padded_avg: 0.000000  tenuring_thresh: 1  target_size: 108003328
PSAdaptiveSizePolicy::compute_eden_space_size: costs minor_time: 0.001995 major_cost: 0.000613 mutator_cost: 0.997392 throughput_goal: 0.990000 live_space: 1098490112 free_space: 2522349568 old_eden_size: 1443889152 desired_eden_size: 1443364864
AdaptiveSizePolicy::survivor space sizes: collection: 1122 (106954752, 524288) -> (56098816, 108003328) 
AdaptiveSizeStop: collection: 1122 
[PSYoungGen: 1451520K->54660K(1464320K)] 2354298K->957446K(4260864K), 0.0585204 secs] [Times: user=0.14 sys=0.00, real=0.06 secs] 
2020-02-05T07:47:02.815-0500: 23603.648: [GC (Metadata GC Threshold) AdaptiveSizePolicy::update_averages:  survived: 10372288  promoted: 54161296  overflow: false
AdaptiveSizeStart: 23603.701 collection: 1123 
  avg_survived_padded_avg: 104833904.000000  avg_promoted_padded_avg: 84380448.000000  avg_pretenured_padded_avg: 0.000000  tenuring_thresh: 1  target_size: 104857600
PSAdaptiveSizePolicy::compute_eden_space_size: costs minor_time: 0.009104 major_cost: 0.000613 mutator_cost: 0.990283 throughput_goal: 0.990000 live_space: 1096590848 free_space: 2521825280 old_eden_size: 1443364864 desired_eden_size: 1402470400
AdaptiveSizePolicy::survivor space sizes: collection: 1123 (10485760, 56098816) -> (10485760, 104857600) 
AdaptiveSizeStop: collection: 1123 
[PSYoungGen: 221390K->10129K(1379840K)] 1124177K->965807K(4176384K), 0.0625170 secs] [Times: user=0.19 sys=0.00, real=0.06 secs] 
2020-02-05T07:47:02.878-0500: 23603.711: [Full GC (Metadata GC Threshold) AdaptiveSizeStart: 23604.878 collection: 1124 
PSAdaptiveSizePolicy::compute_eden_space_size: costs minor_time: 0.009104 major_cost: 0.012509 mutator_cost: 0.978387 throughput_goal: 0.990000 live_space: 1093844224 free_space: 2480930816 old_eden_size: 1402470400 desired_eden_size: 1520959488
PSAdaptiveSizePolicy::compute_old_gen_free_space: costs minor_time: 0.009104 major_cost: 0.012509 mutator_cost: 0.978387 throughput_goal: 0.990000 live_space: 1097600256 free_space: 2599419904 old_promo_size: 1078460416 desired_promo_size: 1328545792
AdaptiveSizeStop: collection: 1124 
[PSYoungGen: 10129K->0K(1379840K)] [ParOldGen: 955678K->804848K(2796544K)] 965807K->804848K(4176384K), [Metaspace: 336946K->336898K(620544K)], 1.1672615 secs] [Times: user=3.28 sys=0.00, real=1.17 secs] 
2020-02-05T07:47:04.046-0500: 23604.879: [GC (Last ditch collection) AdaptiveSizePolicy::update_averages:  survived: 0  promoted: 0  overflow: false
AdaptiveSizeStart: 23604.893 collection: 1125 
  avg_survived_padded_avg: 103366768.000000  avg_promoted_padded_avg: 82075424.000000  avg_pretenured_padded_avg: 0.000000  tenuring_thresh: 2  target_size: 103809024
PSAdaptiveSizePolicy::compute_eden_space_size: costs minor_time: 0.009750 major_cost: 0.012509 mutator_cost: 0.977741 throughput_goal: 0.990000 live_space: 1095128320 free_space: 2849505280 old_eden_size: 1520959488 desired_eden_size: 1525678080
AdaptiveSizePolicy::survivor space sizes: collection: 1125 (104857600, 10485760) -> (104857600, 103809024) 
AdaptiveSizeStop: collection: 1125 
[PSYoungGen: 0K->0K(1513984K)] 804848K->804848K(4310528K), 0.0142603 secs] [Times: user=0.06 sys=0.00, real=0.01 secs] 
2020-02-05T07:47:04.061-0500: 23604.893: [Full GC (Last ditch collection) AdaptiveSizeStart: 23607.663 collection: 1126 
PSAdaptiveSizePolicy::compute_eden_space_size: costs minor_time: 0.009750 major_cost: 0.258044 mutator_cost: 0.732206 throughput_goal: 0.990000 live_space: 1092903552 free_space: 2854223872 old_eden_size: 1525678080 desired_eden_size: 1456472064
PSAdaptiveSizePolicy::compute_old_gen_free_space: costs minor_time: 0.009750 major_cost: 0.258044 mutator_cost: 0.732206 throughput_goal: 0.990000 live_space: 1093117440 free_space: 2785017856 old_promo_size: 1328545792 desired_promo_size: 1713373184
AdaptiveSizeStop: collection: 1126 
[PSYoungGen: 0K->0K(1513984K)] [ParOldGen: 804848K->787083K(2796544K)] 804848K->787083K(4310528K), [Metaspace: 336962K->328764K(620544K)], 2.7696424 secs] [Times: user=6.91 sys=0.03, real=2.77 secs] 

最後のメタスペースの使用状況を見ると、約 328MB でした。 [Metaspace: 336962K->328764K(620544K)]

Java docによると、「MaxMetaspaceSize は、コミットされた圧縮されたクラス スペースと他のクラス メタデータ用のスペースの合計に適用されます。」. 圧縮されたクラスの使用量も確認しましたが、約 50MB でした。

仮想メモリの使用量を確認しました。不足はありませんでした。これは私が混乱しているところです。ご覧のように、Metaspace の使用率が MaxMetaspaceSize の 50% 未満だったのに、JVM が「最後の溝のコレクション」を実行して OOM に移行したのはなぜですか? JDK のバグが発生していますか? また、「1 回限り」のケースではなく、月に 1 ~ 2 回発生します。何かが欠けているかどうかわかりません。誰かが考えを共有してもらえますか?

4

0 に答える 0