privatestaticvoid testGlobalLimit() throws IOException { long smallMemorySize = 1024*1024; // 1m
ProcessBuilder pb = processBuilderWithSetting("-XX:MallocLimit=" + smallMemorySize);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldNotHaveExitValue(0);
output.shouldContain("[nmt] MallocLimit: total limit: 1024K"); // printed by byte_size_in_proper_unit()
String s = output.firstMatch(".*MallocLimit: reached limit \\(size: (\\d+), limit: " + smallMemorySize + "\\).*", 1);
Asserts.assertNotNull(s); long size = Long.parseLong(s);
Asserts.assertGreaterThan(size, smallMemorySize);
}
privatestaticvoid testCompilerLimit() throws IOException { // Here, we count on the VM, running with -Xcomp and with 1m of arena space allowed, will start a compilation // and then trip over the limit. // If limit is too small, Compiler stops too early and we won't get a Retry file (see below, we check that). // If limit is too large, we may not trigger it for java -version. // 1m seems to work out fine. long smallMemorySize = 1024*1024; // 1m
ProcessBuilder pb = processBuilderWithSetting("-XX:MallocLimit=compiler:" + smallMemorySize, "-Xcomp"// make sure we hit the compiler category limit
);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldNotHaveExitValue(0);
output.shouldContain("[nmt] MallocLimit: category \"Compiler\" limit: 1024K"); // printed by byte_size_in_proper_unit
String s = output.firstMatch(".*MallocLimit: category \"Compiler\" reached limit \\(size: (\\d+), limit: " + smallMemorySize + "\\).*", 1);
Asserts.assertNotNull(s); long size = Long.parseLong(s);
output.shouldContain("Compiler replay data is saved as");
Asserts.assertGreaterThan(size, smallMemorySize);
}
privatestaticvoid testInvalidSettings() throws IOException { // Test a number of invalid settings the parser should catch. VM should abort in initialization.
testInvalidSetting("gc", "MallocLimit: colon missing: gc");
testInvalidSetting("gc:abc", "Invalid MallocLimit size: abc");
testInvalidSetting("abcd:10m", "MallocLimit: invalid nmt category: abcd");
testInvalidSetting("nmt:100m,abcd:10m", "MallocLimit: invalid nmt category: abcd");
testInvalidSetting("0", "MallocLimit: limit must be > 0");
testInvalidSetting("GC:0", "MallocLimit: limit must be > 0");
}
privatestaticvoid testLimitWithoutNmt() throws IOException {
ProcessBuilder pb = processBuilderWithSetting("-XX:NativeMemoryTracking=off", // overrides "summary" from processBuilderWithSetting() "-XX:MallocLimit=3g");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.reportDiagnosticSummary();
output.shouldHaveExitValue(0); // Not a fatal error, just a warning
output.shouldContain("MallocLimit will be ignored since NMT is disabled");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.