Mercurial > hg > truffle
annotate test/gc/7168848/HumongousAlloc.java @ 9709:3f647890c067
Fix for BoxingEliminationTest.
author | Christian Haeubl <haeubl@ssw.jku.at> |
---|---|
date | Tue, 14 May 2013 11:49:10 +0200 |
parents | 9a344d88dc22 |
children |
rev | line source |
---|---|
6105
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
1 /* |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
4 * |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
8 * |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
13 * accompanied this code). |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
14 * |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
18 * |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
21 * questions. |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
22 */ |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
23 |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
24 /* |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
25 * @test Humongous.java |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
26 * @bug 7168848 |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
27 * @summary G1: humongous object allocations should initiate marking cycles when necessary |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
28 * @run main/othervm -Xms100m -Xmx100m -XX:+PrintGC -XX:G1HeapRegionSize=1m -XX:+UseG1GC HumongousAlloc |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
29 * |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
30 */ |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
31 import java.lang.management.GarbageCollectorMXBean; |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
32 import java.lang.management.ManagementFactory; |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
33 import java.util.List; |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
34 |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
35 public class HumongousAlloc { |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
36 |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
37 public static byte[] dummy; |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
38 private static int sleepFreq = 40; |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
39 private static int sleepTime = 1000; |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
40 private static double size = 0.75; |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
41 private static int iterations = 50; |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
42 private static int MB = 1024 * 1024; |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
43 |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
44 public static void allocate(int size, int sleepTime, int sleepFreq) throws InterruptedException { |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
45 System.out.println("Will allocate objects of size: " + size |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
46 + " bytes and sleep for " + sleepTime |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
47 + " ms after every " + sleepFreq + "th allocation."); |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
48 int count = 0; |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
49 while (count < iterations) { |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
50 for (int i = 0; i < sleepFreq; i++) { |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
51 dummy = new byte[size - 16]; |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
52 } |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
53 Thread.sleep(sleepTime); |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
54 count++; |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
55 } |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
56 } |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
57 |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
58 public static void main(String[] args) throws InterruptedException { |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
59 allocate((int) (size * MB), sleepTime, sleepFreq); |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
60 List<GarbageCollectorMXBean> collectors = ManagementFactory.getGarbageCollectorMXBeans(); |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
61 for (GarbageCollectorMXBean collector : collectors) { |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
62 if (collector.getName().contains("G1 Old")) { |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
63 long count = collector.getCollectionCount(); |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
64 if (count > 0) { |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
65 throw new RuntimeException("Failed: FullGCs should not have happened. The number of FullGC run is " + count); |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
66 } |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
67 else { |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
68 System.out.println("Passed."); |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
69 } |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
70 } |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
71 } |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
72 } |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
73 } |
9a344d88dc22
7168848: Add test to check that humongous object allocation path also checks the heap occupancy.
mnunez
parents:
diff
changeset
|
74 |