test/gc/7168848/HumongousAlloc.java

changeset 5967
ee99e1a7c5fb
parent 5966
d0453d2fd045
parent 5947
c51cd6af7e61
child 5968
996d1f2f056f
     1.1 --- a/test/gc/7168848/HumongousAlloc.java	Fri Oct 18 10:37:26 2013 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,74 +0,0 @@
     1.4 -/*
     1.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 - *
     1.8 - * This code is free software; you can redistribute it and/or modify it
     1.9 - * under the terms of the GNU General Public License version 2 only, as
    1.10 - * published by the Free Software Foundation.
    1.11 - *
    1.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 - * version 2 for more details (a copy is included in the LICENSE file that
    1.16 - * accompanied this code).
    1.17 - *
    1.18 - * You should have received a copy of the GNU General Public License version
    1.19 - * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 - *
    1.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 - * or visit www.oracle.com if you need additional information or have any
    1.24 - * questions.
    1.25 - */
    1.26 -
    1.27 -/*
    1.28 - * @test Humongous.java
    1.29 - * @bug 7168848
    1.30 - * @summary G1: humongous object allocations should initiate marking cycles when necessary
    1.31 - * @run main/othervm -Xms100m -Xmx100m -XX:+PrintGC -XX:G1HeapRegionSize=1m -XX:+UseG1GC  HumongousAlloc
    1.32 - *
    1.33 - */
    1.34 -import java.lang.management.GarbageCollectorMXBean;
    1.35 -import java.lang.management.ManagementFactory;
    1.36 -import java.util.List;
    1.37 -
    1.38 -public class HumongousAlloc {
    1.39 -
    1.40 -    public static byte[] dummy;
    1.41 -    private static int sleepFreq = 40;
    1.42 -    private static int sleepTime = 1000;
    1.43 -    private static double size = 0.75;
    1.44 -    private static int iterations = 50;
    1.45 -    private static int MB = 1024 * 1024;
    1.46 -
    1.47 -    public static void allocate(int size, int sleepTime, int sleepFreq) throws InterruptedException {
    1.48 -        System.out.println("Will allocate objects of size: " + size
    1.49 -                + " bytes and sleep for " + sleepTime
    1.50 -                + " ms after every " + sleepFreq + "th allocation.");
    1.51 -        int count = 0;
    1.52 -        while (count < iterations) {
    1.53 -            for (int i = 0; i < sleepFreq; i++) {
    1.54 -                dummy = new byte[size - 16];
    1.55 -            }
    1.56 -            Thread.sleep(sleepTime);
    1.57 -            count++;
    1.58 -        }
    1.59 -    }
    1.60 -
    1.61 -    public static void main(String[] args) throws InterruptedException {
    1.62 -        allocate((int) (size * MB), sleepTime, sleepFreq);
    1.63 -        List<GarbageCollectorMXBean> collectors = ManagementFactory.getGarbageCollectorMXBeans();
    1.64 -        for (GarbageCollectorMXBean collector : collectors) {
    1.65 -            if (collector.getName().contains("G1 Old")) {
    1.66 -               long count = collector.getCollectionCount();
    1.67 -                if (count > 0) {
    1.68 -                    throw new RuntimeException("Failed: FullGCs should not have happened. The number of FullGC run is " + count);
    1.69 -                }
    1.70 -                else {
    1.71 -                    System.out.println("Passed.");
    1.72 -                }
    1.73 -            }
    1.74 -        }
    1.75 -    }
    1.76 -}
    1.77 -

mercurial