< prev index next >

test/hotspot/jtreg/gc/shenandoah/oom/TestClassLoaderLeak.java

Print this page

  1 /*
  2  * Copyright (c) 2018, Red Hat, Inc. All rights reserved.

  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *

108             analyzer.shouldNotContain("java.lang.OutOfMemoryError");
109             analyzer.shouldContain("All good");
110         } else {
111             analyzer.shouldHaveExitValue(1);
112             analyzer.shouldContain("java.lang.OutOfMemoryError");
113             analyzer.shouldNotContain("All good");
114         }
115     }
116 
117     public static void main(String[] args) throws Exception {
118         if (args.length > 0) {
119             String classDir = TestClassLoaderLeak.class.getProtectionDomain().getCodeSource().getLocation().getPath();
120             for (int c = 0; c < COUNT; c++) {
121                 load(classDir);
122             }
123             System.out.println("All good");
124             return;
125         }
126 
127         String[][][] modeHeuristics = new String[][][] {
128              {{"satb"},    {"adaptive", "compact", "static", "aggressive"}},
129              {{"iu"},      {"adaptive", "aggressive"}},
130              {{"passive"}, {"passive"}}

131         };
132 
133         for (String[][] mh : modeHeuristics) {
134             String mode = mh[0][0];
135             String[] heuristics = mh[1];
136             for (String h : heuristics) {
137                 // Forceful enabling should work
138                 passWith("-XX:ShenandoahGCMode=" + mode, "-XX:ShenandoahGCHeuristics=" + h, "-XX:+ClassUnloading");
139                 passWith("-XX:ShenandoahGCMode=" + mode, "-XX:ShenandoahGCHeuristics=" + h, "-XX:+ClassUnloadingWithConcurrentMark");
140 
141                 // Even when concurrent unloading is disabled, Full GC has to recover
142                 passWith("-XX:ShenandoahGCMode=" + mode, "-XX:ShenandoahGCHeuristics=" + h, "-XX:+ClassUnloading", "-XX:-ClassUnloadingWithConcurrentMark");
143 
144                 // Should OOME when unloading forcefully disabled, even if local flags try to enable it back
145                 failWith("-XX:ShenandoahGCMode=" + mode, "-XX:ShenandoahGCHeuristics=" + h, "-XX:-ClassUnloading");
146                 failWith("-XX:ShenandoahGCMode=" + mode, "-XX:ShenandoahGCHeuristics=" + h, "-XX:-ClassUnloading", "-XX:+ClassUnloadingWithConcurrentMark");
147             }
148         }
149     }
150 }

  1 /*
  2  * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
  3  * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
  4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5  *
  6  * This code is free software; you can redistribute it and/or modify it
  7  * under the terms of the GNU General Public License version 2 only, as
  8  * published by the Free Software Foundation.
  9  *
 10  * This code is distributed in the hope that it will be useful, but WITHOUT
 11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13  * version 2 for more details (a copy is included in the LICENSE file that
 14  * accompanied this code).
 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  *

109             analyzer.shouldNotContain("java.lang.OutOfMemoryError");
110             analyzer.shouldContain("All good");
111         } else {
112             analyzer.shouldHaveExitValue(1);
113             analyzer.shouldContain("java.lang.OutOfMemoryError");
114             analyzer.shouldNotContain("All good");
115         }
116     }
117 
118     public static void main(String[] args) throws Exception {
119         if (args.length > 0) {
120             String classDir = TestClassLoaderLeak.class.getProtectionDomain().getCodeSource().getLocation().getPath();
121             for (int c = 0; c < COUNT; c++) {
122                 load(classDir);
123             }
124             System.out.println("All good");
125             return;
126         }
127 
128         String[][][] modeHeuristics = new String[][][] {
129              {{"satb"},         {"adaptive", "compact", "static", "aggressive"}},
130              {{"iu"},           {"adaptive", "aggressive"}},
131              {{"passive"},      {"passive"}},
132              {{"generational"}, {"adaptive"}}
133         };
134 
135         for (String[][] mh : modeHeuristics) {
136             String mode = mh[0][0];
137             String[] heuristics = mh[1];
138             for (String h : heuristics) {
139                 // Forceful enabling should work
140                 passWith("-XX:ShenandoahGCMode=" + mode, "-XX:ShenandoahGCHeuristics=" + h, "-XX:+ClassUnloading");
141                 passWith("-XX:ShenandoahGCMode=" + mode, "-XX:ShenandoahGCHeuristics=" + h, "-XX:+ClassUnloadingWithConcurrentMark");
142 
143                 // Even when concurrent unloading is disabled, Full GC has to recover
144                 passWith("-XX:ShenandoahGCMode=" + mode, "-XX:ShenandoahGCHeuristics=" + h, "-XX:+ClassUnloading", "-XX:-ClassUnloadingWithConcurrentMark");
145 
146                 // Should OOME when unloading forcefully disabled, even if local flags try to enable it back
147                 failWith("-XX:ShenandoahGCMode=" + mode, "-XX:ShenandoahGCHeuristics=" + h, "-XX:-ClassUnloading");
148                 failWith("-XX:ShenandoahGCMode=" + mode, "-XX:ShenandoahGCHeuristics=" + h, "-XX:-ClassUnloading", "-XX:+ClassUnloadingWithConcurrentMark");
149             }
150         }
151     }
152 }
< prev index next >