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 */ 23 24 /* 25 * The -XX:MarkSweepAlwaysCompactCount=1 argument below makes sure serial gc 26 * compacts the heap at every full gc so that the usage is correctly updated. 27 */ 28 29 /* 30 * @test 31 * @bug 4892507 32 * @summary Basic Test for MemoryPool.resetPeakUsage() 33 * @author Mandy Chung 34 * 35 * @build ResetPeakMemoryUsage MemoryUtil 36 * @run main/othervm -XX:+UseSerialGC -XX:MarkSweepAlwaysCompactCount=1 -Xmn8m ResetPeakMemoryUsage 37 * @run main/othervm -XX:+UseConcMarkSweepGC -Xmn8m ResetPeakMemoryUsage 38 * @run main/othervm -XX:+UseParallelGC -Xmn8m ResetPeakMemoryUsage 39 * @run main/othervm -XX:+UseG1GC -Xmn8m -XX:G1HeapRegionSize=1m ResetPeakMemoryUsage 40 */ 41 42 import java.lang.management.*; 43 import java.util.*; 44 45 public class ResetPeakMemoryUsage { 46 private static MemoryMXBean mbean = ManagementFactory.getMemoryMXBean(); 47 // make public so that it can't be optimized away easily 48 public static Object[] obj; 49 50 public static void main(String[] argv) { 51 List pools = ManagementFactory.getMemoryPoolMXBeans(); 52 ListIterator iter = pools.listIterator(); 53 boolean found = false; 54 while (iter.hasNext()) { 55 MemoryPoolMXBean p = (MemoryPoolMXBean) iter.next(); 56 // only check heap pools that support usage threshold 57 // this is typically only the old generation space 58 // since the other spaces are expected to get filled up 59 if (p.getType() == MemoryType.HEAP && | 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 */ 23 24 /* 25 * The -XX:MarkSweepAlwaysCompactCount=1 argument below makes sure serial gc 26 * compacts the heap at every full gc so that the usage is correctly updated. 27 */ 28 29 /* 30 * @test 31 * @bug 4892507 32 * @summary Basic Test for MemoryPool.resetPeakUsage() 33 * @author Mandy Chung 34 * 35 * @build ResetPeakMemoryUsage MemoryUtil 36 * @run main/othervm -XX:+PrintGCDetails -XX:+UseSerialGC -Xms256m -XX:MarkSweepAlwaysCompactCount=1 -Xmn8m ResetPeakMemoryUsage 37 * @run main/othervm -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC -Xms256m -Xmn8m ResetPeakMemoryUsage 38 * @run main/othervm -XX:+PrintGCDetails -XX:+UseParallelGC -Xms256m -Xmn8m ResetPeakMemoryUsage 39 * @run main/othervm -XX:+PrintGCDetails -XX:+UseG1GC -Xms256m -Xmn8m -XX:G1HeapRegionSize=1m ResetPeakMemoryUsage 40 */ 41 42 import java.lang.management.*; 43 import java.util.*; 44 45 public class ResetPeakMemoryUsage { 46 private static MemoryMXBean mbean = ManagementFactory.getMemoryMXBean(); 47 // make public so that it can't be optimized away easily 48 public static Object[] obj; 49 50 public static void main(String[] argv) { 51 List pools = ManagementFactory.getMemoryPoolMXBeans(); 52 ListIterator iter = pools.listIterator(); 53 boolean found = false; 54 while (iter.hasNext()) { 55 MemoryPoolMXBean p = (MemoryPoolMXBean) iter.next(); 56 // only check heap pools that support usage threshold 57 // this is typically only the old generation space 58 // since the other spaces are expected to get filled up 59 if (p.getType() == MemoryType.HEAP && |