On Sat, 13 Dec 2025 02:04:27 GMT, Albert Mingkun Yang <[email protected]> wrote:

>> src/hotspot/share/gc/parallel/psParallelCompact.cpp line 1070:
>> 
>>> 1068:     
>>> size_policy->sample_old_gen_used_bytes(MAX2(pre_gc_values.old_gen_used(), 
>>> old_gen->used_in_bytes()));
>>> 1069: 
>>> 1070:     if (UseAdaptiveSizePolicy) {
>> 
>> I think this code block could raise heap size don't expand in some specific 
>> case, maybe you should optimize it. @albertnetymk
>
> @SilenceZheng66 Could you elaborate the issue, ideally, in a JBS ticket? (A 
> reproducer/gc-log would be nice, but detailed description works as well.)

@albertnetymk Sure.  I will give detailed description here.

GC:PS MarkSweep、PS Scavenge

JVM configuraton:  
-Xmx2g 
-Xms256M 
-XX:MetaspaceSize=256m 
-XX:MaxMetaspaceSize=256m 
-XX:+PrintGCDateStamps 
-XX:+PrintGCDetails 
-XX:-UseAdaptiveSizePolicy 
-XX:+PrintAdaptiveSizePolicy 
-XX:+HeapDumpBeforeFullGC 
-XX:+HeapDumpOnOutOfMemoryError 
-XX:HeapDumpPath=export/Logs/ 
-Xloggc:/export/Logs/gclogs.log 

JVM version:25.191-b12, although it's an old version without maintenance, I 
find out the problem might still in the latest version.

Problem Description: 
When starting a application(like SpringBoot), objects loading to VM 
continuously, my CPU usage suddenly began to skyrocket, followed by a full GC 
lasting over ten minutes with more than 2,700 occurrences. Examining the GC 
logs revealed that prior to the full GC, several successful young GC events had 
taken place until the old generation was completely filled. I read the source 
code and find out when -XX:-UseAdaptiveSizePolicy was set,  VM thread can't 
expand psOldGen, only GC worker can expand psOldGen's size in that condition. I 
assume that the transition from the younger generation to the older generation 
has been successful, so that GC worker's expansion was not reached, that made 
long term full GC happened.

Check List:
1. Container has enough place for heap expansion
2. Xms and Xmx were setting differently, same configuration in Serial GC can 
raise heap expansion

GC log sample:
// Full GC Starting
[PSYoungGen: 76276K->10735K(76288K)] 244793K->181638K(251392K), 0.0078092 secs] 
[Times: user=0.04 sys=0.00, real=0.01 secs] 
2025-12-10T14:11:58.663+0800: 24.604: [Heap Dump (before full gc): , 0.0000482 
secs]2025-12-10T14:11:58.663+0800: 24.604: [Full GC (Ergonomics) [PSYoungGen: 
10735K->0K(76288K)] [ParOldGen: 170902K->173351K(175104K)] 
181638K->173351K(251392K), [Metaspace: 107770K->107770K(1146880K)], 0.5258832 
secs] [Times: user=1.82 sys=0.00, real=0.52 secs] 
2025-12-10T14:11:59.268+0800: 25.210: [Heap Dump (before full gc): , 0.0000684 
secs]2025-12-10T14:11:59.269+0800: 25.210: [Full GC (Ergonomics) [PSYoungGen: 
65536K->0K(76288K)] [ParOldGen: 173351K->174276K(175104K)] 
238887K->174276K(251392K), [Metaspace: 109096K->109096K(1148928K)], 0.3031080 
secs] [Times: user=1.10 sys=0.01, real=0.30 secs] 
2025-12-10T14:11:59.710+0800: 25.651: [Heap Dump (before full gc): , 0.0000752 
secs]2025-12-10T14:11:59.710+0800: 25.651: [Full GC (Ergonomics) [PSYoungGen: 
65536K->0K(76288K)] [ParOldGen: 174276K->174980K(175104K)] 
239812K->174980K(251392K), [Metaspace: 110351K->110351K(1148928K)], 0.3664816 
secs] [Times: user=1.21 sys=0.00, real=0.37 secs]
// Full GC Running
2025-12-10T14:12:52.408+0800: 78.350: [Heap Dump (before full gc): , 0.0000535 
secs]2025-12-10T14:12:52.409+0800: 78.350: [Full GC (Ergonomics) [PSYoungGen: 
65536K->64255K(76288K)] [ParOldGen: 174893K->174893K(175104K)] 
240429K->239149K(251392K), [Metaspace: 148330K->148330K(1183744K)], 0.2442300 
secs] [Times: user=0.68 sys=0.00, real=0.25 secs] 
2025-12-10T14:12:52.656+0800: 78.598: [Heap Dump (before full gc): , 0.0000711 
secs]2025-12-10T14:12:52.657+0800: 78.598: [Full GC (Ergonomics) [PSYoungGen: 
65536K->64333K(76288K)] [ParOldGen: 174893K->174893K(175104K)] 
240429K->239227K(251392K), [Metaspace: 148379K->148379K(1183744K)], 0.2102640 
secs] [Times: user=0.53 sys=0.02, real=0.21 secs] 
2025-12-10T14:12:52.871+0800: 78.813: [Heap Dump (before full gc): , 0.0000622 
secs]2025-12-10T14:12:52.872+0800: 78.813: [Full GC (Ergonomics) [PSYoungGen: 
65534K->64252K(76288K)] [ParOldGen: 174893K->174893K(175104K)] 
240428K->239146K(251392K), [Metaspace: 148488K->148488K(1183744K)], 0.2125166 
secs] [Times: user=0.54 sys=0.00, real=0.22 secs]  
// Full GC Ending
2025-12-10T14:32:47.691+0800: 1273.632: [Heap Dump (before full gc): , 
0.0000943 secs]2025-12-10T14:32:47.691+0800: 1273.633: [Full GC (Ergonomics) 
[PSYoungGen: 65536K->24273K(76288K)] [ParOldGen: 174627K->174626K(175104K)] 
240163K->198899K(251392K), [Metaspace: 152567K->152567K(1187840K)], 0.3627505 
secs] [Times: user=1.12 sys=0.00, real=0.37 secs] 
2025-12-10T14:35:18.172+0800: 1424.113: [Heap Dump (before full gc): , 
0.0001014 secs]2025-12-10T14:35:18.172+0800: 1424.114: [Full GC (Ergonomics) 
[PSYoungGen: 65536K->9012K(76288K)] [ParOldGen: 174626K->174852K(175104K)] 
240162K->183865K(251392K), [Metaspace: 152611K->152611K(1187840K)], 0.2574051 
secs] [Times: user=0.63 sys=0.00, real=0.26 secs] 
2025-12-10T14:38:49.044+0800: 1634.986: [Heap Dump (before full gc): , 
0.0001049 secs]2025-12-10T14:38:49.045+0800: 1634.987: [Full GC (Ergonomics) 
[PSYoungGen: 65536K->0K(76288K)] [ParOldGen: 174852K->133113K(175104K)] 
240388K->133113K(251392K), [Metaspace: 152680K->152680K(1187840K)], 0.3655573 
secs] [Times: user=1.01 sys=0.00, real=0.36 secs] 
2025-12-10T14:42:49.842+0800: 1875.784: [GC (Allocation Failure) 
AdaptiveSizePolicy::update_averages:  survived: 1671680  promoted: 0  overflow: 
false

If you need other details just let me know, thx!

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25000#discussion_r2619293977

Reply via email to