8025226: TestPerfCountersAndMemoryPools.java fails with -Xmixed or -Xcomp
Reviewed-by: brutisso, mgerdin
This commit is contained in:
parent
ce8f16808b
commit
2722c5d966
@ -29,10 +29,11 @@ import static com.oracle.java.testlibrary.Asserts.*;
|
||||
|
||||
/* @test TestPerfCountersAndMemoryPools
|
||||
* @bug 8023476
|
||||
* @library /testlibrary
|
||||
* @summary Tests that a MemoryPoolMXBeans and PerfCounters for metaspace
|
||||
* report the same data.
|
||||
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData TestPerfCountersAndMemoryPools
|
||||
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData TestPerfCountersAndMemoryPools
|
||||
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools
|
||||
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools
|
||||
*/
|
||||
public class TestPerfCountersAndMemoryPools {
|
||||
public static void main(String[] args) throws Exception {
|
||||
@ -43,11 +44,11 @@ public class TestPerfCountersAndMemoryPools {
|
||||
}
|
||||
}
|
||||
|
||||
private static MemoryUsage getMemoryUsage(String memoryPoolName) {
|
||||
private static MemoryPoolMXBean getMemoryPool(String memoryPoolName) {
|
||||
List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
|
||||
for (MemoryPoolMXBean pool : pools) {
|
||||
if (pool.getName().equals(memoryPoolName)) {
|
||||
return pool.getUsage();
|
||||
return pool;
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,19 +58,18 @@ public class TestPerfCountersAndMemoryPools {
|
||||
|
||||
private static void checkMemoryUsage(String memoryPoolName, String perfNS)
|
||||
throws Exception {
|
||||
// Need to do a gc before each comparison to update the perf counters
|
||||
MemoryPoolMXBean pool = getMemoryPool(memoryPoolName);
|
||||
|
||||
// Must do a GC to update performance counters
|
||||
System.gc();
|
||||
MemoryUsage mu = getMemoryUsage(memoryPoolName);
|
||||
assertEQ(getMinCapacity(perfNS), mu.getInit());
|
||||
assertEQ(getMinCapacity(perfNS), pool.getUsage().getInit());
|
||||
|
||||
// Must do a second GC to update the perfomance counters again, since
|
||||
// the call pool.getUsage().getInit() could have allocated some
|
||||
// metadata.
|
||||
System.gc();
|
||||
mu = getMemoryUsage(memoryPoolName);
|
||||
assertEQ(getUsed(perfNS), mu.getUsed());
|
||||
|
||||
System.gc();
|
||||
mu = getMemoryUsage(memoryPoolName);
|
||||
assertEQ(getCapacity(perfNS), mu.getCommitted());
|
||||
assertEQ(getUsed(perfNS), pool.getUsage().getUsed());
|
||||
assertEQ(getCapacity(perfNS), pool.getUsage().getCommitted());
|
||||
}
|
||||
|
||||
private static long getMinCapacity(String ns) throws Exception {
|
||||
|
Loading…
Reference in New Issue
Block a user