|
1 | 1 | /*
|
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. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
31 | 31 | *
|
32 | 32 | * @library /vmTestbase
|
33 | 33 | * /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 |
35 | 37 | */
|
36 | 38 |
|
37 | 39 | package gc.gctests.LoadUnloadGC2;
|
38 | 40 |
|
| 41 | +import jdk.test.whitebox.WhiteBox; |
39 | 42 | import nsk.share.*;
|
40 | 43 | import nsk.share.test.*;
|
41 | 44 | import nsk.share.gc.*;
|
|
44 | 47 | import java.lang.reflect.Array;
|
45 | 48 |
|
46 | 49 | public class LoadUnloadGC2 extends GCTestBase {
|
| 50 | + private static int CYCLE = 1000; |
47 | 51 | public void run() {
|
48 | 52 | Stresser stresser = new Stresser(runParams.getStressOptions());
|
49 | 53 | stresser.start(500000);
|
| 54 | + int iteration = 0; |
50 | 55 | try {
|
| 56 | + GarbageProducer garbageProducer = new GeneratedClassProducer(); |
51 | 57 | 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 | + } |
56 | 68 | }
|
57 | 69 | } finally {
|
58 | 70 | stresser.finish();
|
|
0 commit comments