60 memoryPoolName);
61 }
62
63 private static void checkMemoryUsage(String memoryPoolName, String perfNS)
64 throws Exception {
65 MemoryPoolMXBean pool = getMemoryPool(memoryPoolName);
66
67 // First, call all the methods to let them allocate their own slab of metadata
68 getMinCapacity(perfNS);
69 getCapacity(perfNS);
70 getUsed(perfNS);
71 pool.getUsage().getInit();
72 pool.getUsage().getUsed();
73 pool.getUsage().getCommitted();
74 assertEQ(1L, 1L, "Make assert load");
75
76 // Must do a GC to update performance counters
77 System.gc();
78 assertEQ(getMinCapacity(perfNS), pool.getUsage().getInit(), "MinCapacity out of sync");
79
80 // Adding a second GC due to metadata allocations caused caused by getting
81 // initial size from the pool. This is needed when running with -Xcomp.
82 System.gc();
83 assertEQ(getUsed(perfNS), pool.getUsage().getUsed(), "Used out of sync");
84 assertEQ(getCapacity(perfNS), pool.getUsage().getCommitted(), "Committed out of sync");
85 }
86
87 private static long getMinCapacity(String ns) throws Exception {
88 return PerfCounters.findByName(ns + ".minCapacity").longValue();
89 }
90
91 private static long getCapacity(String ns) throws Exception {
92 return PerfCounters.findByName(ns + ".capacity").longValue();
93 }
94
95 private static long getUsed(String ns) throws Exception {
96 return PerfCounters.findByName(ns + ".used").longValue();
97 }
98 }
|
60 memoryPoolName);
61 }
62
63 private static void checkMemoryUsage(String memoryPoolName, String perfNS)
64 throws Exception {
65 MemoryPoolMXBean pool = getMemoryPool(memoryPoolName);
66
67 // First, call all the methods to let them allocate their own slab of metadata
68 getMinCapacity(perfNS);
69 getCapacity(perfNS);
70 getUsed(perfNS);
71 pool.getUsage().getInit();
72 pool.getUsage().getUsed();
73 pool.getUsage().getCommitted();
74 assertEQ(1L, 1L, "Make assert load");
75
76 // Must do a GC to update performance counters
77 System.gc();
78 assertEQ(getMinCapacity(perfNS), pool.getUsage().getInit(), "MinCapacity out of sync");
79
80 // Adding a second GC due to metadata allocations caused by getting the
81 // initial size from the pool. This is needed when running with -Xcomp.
82 System.gc();
83 assertEQ(getUsed(perfNS), pool.getUsage().getUsed(), "Used out of sync");
84 assertEQ(getCapacity(perfNS), pool.getUsage().getCommitted(), "Committed out of sync");
85 }
86
87 private static long getMinCapacity(String ns) throws Exception {
88 return PerfCounters.findByName(ns + ".minCapacity").longValue();
89 }
90
91 private static long getCapacity(String ns) throws Exception {
92 return PerfCounters.findByName(ns + ".capacity").longValue();
93 }
94
95 private static long getUsed(String ns) throws Exception {
96 return PerfCounters.findByName(ns + ".used").longValue();
97 }
98 }
|