8370731: Tests in vmTestbase/nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/ failed: OutOfMemoryError

Reviewed-by: sspitsyn
This commit is contained in:
Kevin Walls 2025-12-11 07:44:10 +00:00
parent 74dca863c2
commit 920a99faeb
5 changed files with 38 additions and 35 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,9 +29,10 @@
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters001.
* VM Testbase keywords: [monitoring]
*
* @requires vm.opt.DisableExplicitGC != "true"
* @library /vmTestbase
* /test/lib
* @run main/othervm
* @run main/othervm -XX:-UseGCOverheadLimit
* nsk.monitoring.GarbageCollectorMXBean.CollectionCounters.CollectionCounters001.CollectionCounters001
* -testMode=directly
*/
@ -60,6 +61,7 @@ import nsk.share.runner.RunParamsAware;
* time. It may be false with -XX:+DisableExplicitGC.
*/
public class CollectionCounters001 extends MonitoringTestBase implements RunParamsAware, Initializable {
private List<GarbageCollectorMXBean> gcBeans;
private MemoryMXBean memory;
Stresser stresser;
@ -76,18 +78,21 @@ public class CollectionCounters001 extends MonitoringTestBase implements RunPara
private void runOne(ExecutionController stresser) {
updateCounters();
validate();
Algorithms.eatMemory(stresser);
if(stresser.continueExecution()) {
validate(false /* don't check gc count increases */);
int iteration = 0;
do {
System.out.println("=========== stresser iter: " + (stresser.getIteration())
+ " runOne iter: " + (++iteration) + " ===========");
Algorithms.eatMemory(stresser);
updateCounters();
validateNonTrivial();
validate(true);
System.gc();
updateCounters();
validateNonTrivial();
validate(true);
memory.gc();
updateCounters();
validateNonTrivial();
}
validate(true);
} while (stresser.continueExecution());
}
public void run() {
@ -98,26 +103,20 @@ public class CollectionCounters001 extends MonitoringTestBase implements RunPara
}
}
private void validate() {
private void validate(boolean gcCountMustIncrease) {
if (collectionCount < 0)
throw new TestFailure("collectionCount negative: " + collectionCount);
throw new TestFailure("collectionCount negative: " + collectionCount);
if (collectionTime < 0)
throw new TestFailure("collectionTime negative: " + collectionTime);
if (collectionCount < collectionCountOld)
throw new TestFailure("collectionTime negative: " + collectionTime);
if (collectionTime < collectionTimeOld)
throw new TestFailure("collectionTime decreased: " + collectionTime + " -> " + collectionTimeOld);
if (!gcCountMustIncrease) {
if (collectionCount < collectionCountOld)
throw new TestFailure("collectionCount decreased: " + collectionCount + " -> " + collectionCountOld);
if (collectionTime < collectionTimeOld)
throw new TestFailure("collectionTime decreased: " + collectionTime + " -> " + collectionTimeOld);
}
private void validateNonTrivial() {
if (collectionCount < 0)
throw new TestFailure("collectionCount negative: " + collectionCount);
if (collectionTime < 0)
throw new TestFailure("collectionTime negative: " + collectionTime);
if (collectionCount <= collectionCountOld)
} else {
if (collectionCount <= collectionCountOld)
throw new TestFailure("collectionCount not increased: " + collectionCount + " -> " + collectionCountOld);
if (collectionTime < collectionTimeOld)
throw new TestFailure("collection time became smaller: " + collectionTime + " -> " + collectionTimeOld);
}
}
private void updateCounters() {
@ -126,8 +125,8 @@ public class CollectionCounters001 extends MonitoringTestBase implements RunPara
collectionCount = 0;
collectionTime = 0;
for (GarbageCollectorMXBean gcBean : gcBeans) {
collectionCount += gcBean.getCollectionCount();
collectionTime += gcBean.getCollectionTime();
collectionCount += gcBean.getCollectionCount();
collectionTime += gcBean.getCollectionTime();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,9 +29,10 @@
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters002.
* VM Testbase keywords: [monitoring]
*
* @requires vm.opt.DisableExplicitGC != "true"
* @library /vmTestbase
* /test/lib
* @run main/othervm
* @run main/othervm -XX:-UseGCOverheadLimit
* nsk.monitoring.GarbageCollectorMXBean.CollectionCounters.CollectionCounters001.CollectionCounters001
* -testMode=server
* -MBeanServer=default

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,9 +29,10 @@
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters003.
* VM Testbase keywords: [monitoring]
*
* @requires vm.opt.DisableExplicitGC != "true"
* @library /vmTestbase
* /test/lib
* @run main/othervm
* @run main/othervm -XX:-UseGCOverheadLimit
* nsk.monitoring.GarbageCollectorMXBean.CollectionCounters.CollectionCounters001.CollectionCounters001
* -testMode=server
* -MBeanServer=custom

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,9 +29,10 @@
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters004.
* VM Testbase keywords: [monitoring]
*
* @requires vm.opt.DisableExplicitGC != "true"
* @library /vmTestbase
* /test/lib
* @run main/othervm
* @run main/othervm -XX:-UseGCOverheadLimit
* nsk.monitoring.GarbageCollectorMXBean.CollectionCounters.CollectionCounters001.CollectionCounters001
* -testMode=proxy
* -MBeanServer=default

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,9 +29,10 @@
* @summary converted from VM Testbase nsk/monitoring/GarbageCollectorMXBean/CollectionCounters/CollectionCounters005.
* VM Testbase keywords: [monitoring]
*
* @requires vm.opt.DisableExplicitGC != "true"
* @library /vmTestbase
* /test/lib
* @run main/othervm
* @run main/othervm -XX:-UseGCOverheadLimit
* nsk.monitoring.GarbageCollectorMXBean.CollectionCounters.CollectionCounters001.CollectionCounters001
* -testMode=proxy
* -MBeanServer=custom