2014-03-17 09:12:21 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014, 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
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2014-05-11 23:35:43 +00:00
|
|
|
* @test TestGCLogMessages
|
2015-01-07 14:15:37 +00:00
|
|
|
* @bug 8035406 8027295 8035398 8019342 8027959 8048179
|
2014-03-17 09:12:21 +00:00
|
|
|
* @summary Ensure that the PrintGCDetails output for a minor GC with G1
|
|
|
|
* includes the expected necessary messages.
|
|
|
|
* @key gc
|
|
|
|
* @library /testlibrary
|
|
|
|
*/
|
|
|
|
|
|
|
|
import com.oracle.java.testlibrary.ProcessTools;
|
|
|
|
import com.oracle.java.testlibrary.OutputAnalyzer;
|
|
|
|
|
|
|
|
public class TestGCLogMessages {
|
|
|
|
public static void main(String[] args) throws Exception {
|
2014-03-17 09:13:42 +00:00
|
|
|
testNormalLogs();
|
|
|
|
testWithToSpaceExhaustionLogs();
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void testNormalLogs() throws Exception {
|
2014-03-17 09:12:21 +00:00
|
|
|
|
|
|
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
|
|
|
|
"-Xmx10M",
|
|
|
|
GCTest.class.getName());
|
|
|
|
|
|
|
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
|
|
|
|
2014-03-17 09:13:27 +00:00
|
|
|
output.shouldNotContain("[Redirty Cards");
|
2014-04-16 14:46:58 +00:00
|
|
|
output.shouldNotContain("[Parallel Redirty");
|
|
|
|
output.shouldNotContain("[Redirtied Cards");
|
2014-03-17 09:13:18 +00:00
|
|
|
output.shouldNotContain("[Code Root Purge");
|
2014-03-18 18:07:22 +00:00
|
|
|
output.shouldNotContain("[String Dedup Fixup");
|
2014-03-17 09:13:18 +00:00
|
|
|
output.shouldNotContain("[Young Free CSet");
|
|
|
|
output.shouldNotContain("[Non-Young Free CSet");
|
2015-01-07 14:15:37 +00:00
|
|
|
output.shouldNotContain("[Humongous Register");
|
2014-07-23 07:03:32 +00:00
|
|
|
output.shouldNotContain("[Humongous Reclaim");
|
2014-03-17 09:13:18 +00:00
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
|
|
|
|
pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
|
2014-03-18 18:07:22 +00:00
|
|
|
"-XX:+UseStringDeduplication",
|
2014-03-17 09:13:18 +00:00
|
|
|
"-Xmx10M",
|
|
|
|
"-XX:+PrintGCDetails",
|
|
|
|
GCTest.class.getName());
|
|
|
|
|
|
|
|
output = new OutputAnalyzer(pb.start());
|
|
|
|
|
2014-03-17 09:13:27 +00:00
|
|
|
output.shouldContain("[Redirty Cards");
|
2014-04-16 14:46:58 +00:00
|
|
|
output.shouldNotContain("[Parallel Redirty");
|
|
|
|
output.shouldNotContain("[Redirtied Cards");
|
2014-03-17 09:13:18 +00:00
|
|
|
output.shouldContain("[Code Root Purge");
|
2014-03-18 18:07:22 +00:00
|
|
|
output.shouldContain("[String Dedup Fixup");
|
2014-03-17 09:13:18 +00:00
|
|
|
output.shouldNotContain("[Young Free CSet");
|
|
|
|
output.shouldNotContain("[Non-Young Free CSet");
|
2015-01-07 14:15:37 +00:00
|
|
|
output.shouldContain("[Humongous Register");
|
2014-07-23 07:03:32 +00:00
|
|
|
output.shouldNotContain("[Humongous Total");
|
|
|
|
output.shouldNotContain("[Humongous Candidate");
|
2015-01-07 14:15:37 +00:00
|
|
|
output.shouldContain("[Humongous Reclaim");
|
2014-07-23 07:03:32 +00:00
|
|
|
output.shouldNotContain("[Humongous Reclaimed");
|
2014-03-17 09:13:18 +00:00
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
|
|
|
|
pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
|
2014-03-18 18:07:22 +00:00
|
|
|
"-XX:+UseStringDeduplication",
|
2014-03-17 09:13:18 +00:00
|
|
|
"-Xmx10M",
|
|
|
|
"-XX:+PrintGCDetails",
|
|
|
|
"-XX:+UnlockExperimentalVMOptions",
|
|
|
|
"-XX:G1LogLevel=finest",
|
|
|
|
GCTest.class.getName());
|
|
|
|
|
|
|
|
output = new OutputAnalyzer(pb.start());
|
|
|
|
|
2014-03-17 09:13:27 +00:00
|
|
|
output.shouldContain("[Redirty Cards");
|
2014-04-16 14:46:58 +00:00
|
|
|
output.shouldContain("[Parallel Redirty");
|
|
|
|
output.shouldContain("[Redirtied Cards");
|
2014-03-17 09:12:21 +00:00
|
|
|
output.shouldContain("[Code Root Purge");
|
2014-03-18 18:07:22 +00:00
|
|
|
output.shouldContain("[String Dedup Fixup");
|
2014-03-17 09:13:18 +00:00
|
|
|
output.shouldContain("[Young Free CSet");
|
|
|
|
output.shouldContain("[Non-Young Free CSet");
|
2015-01-07 14:15:37 +00:00
|
|
|
output.shouldContain("[Humongous Register");
|
2014-07-23 07:03:32 +00:00
|
|
|
output.shouldContain("[Humongous Total");
|
|
|
|
output.shouldContain("[Humongous Candidate");
|
2015-01-07 14:15:37 +00:00
|
|
|
output.shouldContain("[Humongous Reclaim");
|
2014-07-23 07:03:32 +00:00
|
|
|
output.shouldContain("[Humongous Reclaimed");
|
2014-03-17 09:12:21 +00:00
|
|
|
output.shouldHaveExitValue(0);
|
2014-03-17 09:13:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void testWithToSpaceExhaustionLogs() throws Exception {
|
|
|
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
|
2015-01-12 22:43:34 +00:00
|
|
|
"-Xmx32M",
|
|
|
|
"-Xmn16M",
|
2014-03-17 09:13:42 +00:00
|
|
|
"-XX:+PrintGCDetails",
|
|
|
|
GCTestWithToSpaceExhaustion.class.getName());
|
2014-03-17 09:13:18 +00:00
|
|
|
|
2014-03-17 09:13:42 +00:00
|
|
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
|
|
|
output.shouldContain("[Evacuation Failure");
|
|
|
|
output.shouldNotContain("[Recalculate Used");
|
|
|
|
output.shouldNotContain("[Remove Self Forwards");
|
|
|
|
output.shouldNotContain("[Restore RemSet");
|
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
|
|
|
|
pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
|
2015-01-12 22:43:34 +00:00
|
|
|
"-Xmx32M",
|
|
|
|
"-Xmn16M",
|
2014-03-17 09:13:42 +00:00
|
|
|
"-XX:+PrintGCDetails",
|
|
|
|
"-XX:+UnlockExperimentalVMOptions",
|
|
|
|
"-XX:G1LogLevel=finest",
|
|
|
|
GCTestWithToSpaceExhaustion.class.getName());
|
|
|
|
|
|
|
|
output = new OutputAnalyzer(pb.start());
|
|
|
|
output.shouldContain("[Evacuation Failure");
|
|
|
|
output.shouldContain("[Recalculate Used");
|
|
|
|
output.shouldContain("[Remove Self Forwards");
|
|
|
|
output.shouldContain("[Restore RemSet");
|
|
|
|
output.shouldHaveExitValue(0);
|
2014-03-17 09:12:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static class GCTest {
|
|
|
|
private static byte[] garbage;
|
|
|
|
public static void main(String [] args) {
|
|
|
|
System.out.println("Creating garbage");
|
|
|
|
// create 128MB of garbage. This should result in at least one GC
|
|
|
|
for (int i = 0; i < 1024; i++) {
|
|
|
|
garbage = new byte[128 * 1024];
|
|
|
|
}
|
|
|
|
System.out.println("Done");
|
|
|
|
}
|
|
|
|
}
|
2014-03-17 09:13:42 +00:00
|
|
|
|
|
|
|
static class GCTestWithToSpaceExhaustion {
|
|
|
|
private static byte[] garbage;
|
|
|
|
private static byte[] largeObject;
|
|
|
|
public static void main(String [] args) {
|
2015-01-12 22:43:34 +00:00
|
|
|
largeObject = new byte[16*1024*1024];
|
2014-03-17 09:13:42 +00:00
|
|
|
System.out.println("Creating garbage");
|
|
|
|
// create 128MB of garbage. This should result in at least one GC,
|
|
|
|
// some of them with to-space exhaustion.
|
|
|
|
for (int i = 0; i < 1024; i++) {
|
|
|
|
garbage = new byte[128 * 1024];
|
|
|
|
}
|
|
|
|
System.out.println("Done");
|
|
|
|
}
|
|
|
|
}
|
2014-03-17 09:12:21 +00:00
|
|
|
}
|