Mercurial > hg > truffle
annotate test/gc/class_unloading/AllocateBeyondMetaspaceSize.java @ 20427:fe6dafcd8ed0
8055904: Develop tests for new command-line options related to SHA intrinsics
Reviewed-by: kvn, iignatyev
author | fzhinkin |
---|---|
date | Wed, 03 Sep 2014 15:29:57 +0400 |
parents | f3aeae1f9fc5 |
children |
rev | line source |
---|---|
20282
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
1 /* |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
4 * |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
8 * |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
13 * accompanied this code). |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
14 * |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
18 * |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
21 * questions. |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
22 */ |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
23 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
24 import sun.hotspot.WhiteBox; |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
25 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
26 class AllocateBeyondMetaspaceSize { |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
27 public static Object dummy; |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
28 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
29 public static void main(String [] args) { |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
30 if (args.length != 2) { |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
31 throw new IllegalArgumentException("Usage: <MetaspaceSize> <YoungGenSize>"); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
32 } |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
33 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
34 long metaspaceSize = Long.parseLong(args[0]); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
35 long youngGenSize = Long.parseLong(args[1]); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
36 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
37 run(metaspaceSize, youngGenSize); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
38 } |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
39 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
40 private static void run(long metaspaceSize, long youngGenSize) { |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
41 WhiteBox wb = WhiteBox.getWhiteBox(); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
42 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
43 long allocationBeyondMetaspaceSize = metaspaceSize * 2; |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
44 long metaspace = wb.allocateMetaspace(null, allocationBeyondMetaspaceSize); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
45 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
46 triggerYoungGC(youngGenSize); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
47 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
48 wb.freeMetaspace(null, metaspace, metaspace); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
49 } |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
50 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
51 private static void triggerYoungGC(long youngGenSize) { |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
52 long approxAllocSize = 32 * 1024; |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
53 long numAllocations = 2 * youngGenSize / approxAllocSize; |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
54 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
55 for (long i = 0; i < numAllocations; i++) { |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
56 dummy = new byte[(int)approxAllocSize]; |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
57 } |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
58 } |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
59 } |