Skip to content

Commit 9b7f3f9

Browse files
committed
8282642: vmTestbase/gc/gctests/LoadUnloadGC2/LoadUnloadGC2.java fails intermittently with exit code 1
Reviewed-by: phh Backport-of: 7db5abddd126db388b1a7f89be258e8aa7104da7
1 parent 192179e commit 9b7f3f9

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

test/hotspot/jtreg/vmTestbase/gc/gctests/LoadUnloadGC2/LoadUnloadGC2.java

+18-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -31,12 +31,14 @@
3131
*
3232
* @library /vmTestbase
3333
* /test/lib
34-
* @run driver jdk.test.lib.FileInstaller . .
35-
* @run main/othervm -XX:-UseGCOverheadLimit gc.gctests.LoadUnloadGC2.LoadUnloadGC2
34+
* @build sun.hotspot.WhiteBox
35+
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
36+
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI gc.gctests.LoadUnloadGC2.LoadUnloadGC2
3637
*/
3738

3839
package gc.gctests.LoadUnloadGC2;
3940

41+
import sun.hotspot.WhiteBox;
4042
import nsk.share.*;
4143
import nsk.share.test.*;
4244
import nsk.share.gc.*;
@@ -45,15 +47,24 @@
4547
import java.lang.reflect.Array;
4648

4749
public class LoadUnloadGC2 extends GCTestBase {
50+
private static int CYCLE = 1000;
4851
public void run() {
4952
Stresser stresser = new Stresser(runParams.getStressOptions());
5053
stresser.start(500000);
54+
int iteration = 0;
5155
try {
56+
GarbageProducer garbageProducer = new GeneratedClassProducer();
5257
while (stresser.iteration()) {
53-
GarbageProducer garbageProducer = new GeneratedClassProducer();
54-
log.info("Iteration: " + stresser.getIteration());
55-
GarbageUtils.eatMemory(stresser, garbageProducer, 0);
56-
garbageProducer = null;
58+
garbageProducer.create(512L);
59+
if(iteration++ > CYCLE) {
60+
// Unload once every cycle.
61+
iteration = 0;
62+
garbageProducer = null;
63+
// Perform GC so that
64+
// class gets unloaded
65+
WhiteBox.getWhiteBox().fullGC();
66+
garbageProducer = new GeneratedClassProducer();
67+
}
5768
}
5869
} finally {
5970
stresser.finish();

0 commit comments

Comments
 (0)