Skip to content

Commit 7db5abd

Browse files
Ramkumar Sunderbabulmesnik
Ramkumar Sunderbabu
authored andcommitted
8282642: vmTestbase/gc/gctests/LoadUnloadGC2/LoadUnloadGC2.java fails intermittently with exit code 1
Reviewed-by: lmesnik
1 parent 124fc4a commit 7db5abd

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

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

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2020, 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,11 +31,14 @@
3131
*
3232
* @library /vmTestbase
3333
* /test/lib
34-
* @run main/othervm -XX:-UseGCOverheadLimit gc.gctests.LoadUnloadGC2.LoadUnloadGC2
34+
* @build jdk.test.whitebox.WhiteBox
35+
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
36+
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI gc.gctests.LoadUnloadGC2.LoadUnloadGC2
3537
*/
3638

3739
package gc.gctests.LoadUnloadGC2;
3840

41+
import jdk.test.whitebox.WhiteBox;
3942
import nsk.share.*;
4043
import nsk.share.test.*;
4144
import nsk.share.gc.*;
@@ -44,15 +47,24 @@
4447
import java.lang.reflect.Array;
4548

4649
public class LoadUnloadGC2 extends GCTestBase {
50+
private static int CYCLE = 1000;
4751
public void run() {
4852
Stresser stresser = new Stresser(runParams.getStressOptions());
4953
stresser.start(500000);
54+
int iteration = 0;
5055
try {
56+
GarbageProducer garbageProducer = new GeneratedClassProducer();
5157
while (stresser.iteration()) {
52-
GarbageProducer garbageProducer = new GeneratedClassProducer();
53-
log.info("Iteration: " + stresser.getIteration());
54-
GarbageUtils.eatMemory(stresser, garbageProducer, 0);
55-
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+
}
5668
}
5769
} finally {
5870
stresser.finish();

0 commit comments

Comments
 (0)