8179242: OutOfMemoryError in java/util/Arrays/ParallelPrefix.java
Reviewed-by: psandoz
This commit is contained in:
parent
a40a1cb6c0
commit
b0c6781aaa
jdk/test
@ -18,7 +18,7 @@ keys=2d dnd i18n intermittent randomness headful
|
||||
othervm.dirs=java/awt java/beans javax/accessibility javax/imageio javax/sound javax/print javax/management com/sun/awt sun/awt sun/java2d sun/pisces javax/xml/jaxp/testng/validation java/lang/ProcessHandle
|
||||
|
||||
# Tests that cannot run concurrently
|
||||
exclusiveAccess.dirs=java/rmi/Naming java/util/prefs sun/management/jmxremote sun/tools/jstatd sun/security/mscapi java/util/stream java/util/BitSet/stream javax/rmi com/sun/corba/cachedSocket
|
||||
exclusiveAccess.dirs=java/rmi/Naming java/util/prefs sun/management/jmxremote sun/tools/jstatd sun/security/mscapi java/util/stream java/util/Arrays/largeMemory java/util/BitSet/stream javax/rmi com/sun/corba/cachedSocket
|
||||
|
||||
# Group definitions
|
||||
groups=TEST.groups [closed/TEST.groups]
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -641,6 +641,7 @@ needs_compact3 = \
|
||||
java/security/PermissionCollection/Concurrent.java \
|
||||
java/security/Principal/Implies.java \
|
||||
java/security/cert/GetInstance.java \
|
||||
java/util/Arrays/largeMemory/ParallelPrefix.java \
|
||||
java/util/logging/DrainFindDeadlockTest.java \
|
||||
java/util/logging/LoggingMXBeanTest.java \
|
||||
java/util/logging/TestLogConfigurationDeadLock.java \
|
||||
@ -709,7 +710,6 @@ needs_compact2 = \
|
||||
java/nio/Buffer/Chars.java \
|
||||
java/nio/file/Files/StreamTest.java \
|
||||
java/security/BasicPermission/Wildcard.java \
|
||||
java/util/Arrays/ParallelPrefix.java \
|
||||
java/util/Arrays/SetAllTest.java \
|
||||
java/util/BitSet/stream/BitSetStreamTest.java \
|
||||
java/util/Collection/CollectionDefaults.java \
|
||||
|
@ -25,9 +25,11 @@
|
||||
* @test 8014076 8025067
|
||||
* @summary unit test for Arrays.ParallelPrefix().
|
||||
* @author Tristan Yan
|
||||
* @run testng ParallelPrefix
|
||||
* @modules java.management jdk.management
|
||||
* @run testng/othervm -Xms256m -Xmx1024m ParallelPrefix
|
||||
*/
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.BinaryOperator;
|
||||
import java.util.function.DoubleBinaryOperator;
|
||||
@ -36,9 +38,11 @@ import java.util.function.IntBinaryOperator;
|
||||
import java.util.function.LongBinaryOperator;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.LongStream;
|
||||
import com.sun.management.OperatingSystemMXBean;
|
||||
import static org.testng.Assert.*;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
|
||||
public class ParallelPrefix {
|
||||
//Array size less than MIN_PARTITION
|
||||
@ -53,12 +57,37 @@ public class ParallelPrefix {
|
||||
//Array size much greater than MIN_PARTITION
|
||||
private static final int LARGE_ARRAY_SIZE = 1 << 14;
|
||||
|
||||
private static final int[] ARRAY_SIZE_COLLECTION = new int[]{
|
||||
SMALL_ARRAY_SIZE,
|
||||
THRESHOLD_ARRAY_SIZE,
|
||||
MEDIUM_ARRAY_SIZE,
|
||||
LARGE_ARRAY_SIZE
|
||||
};
|
||||
private static int[] arraySizeCollection;
|
||||
|
||||
@BeforeSuite
|
||||
public static void setup() {
|
||||
java.lang.management.OperatingSystemMXBean bean =
|
||||
ManagementFactory.getOperatingSystemMXBean();
|
||||
if (bean instanceof OperatingSystemMXBean) {
|
||||
OperatingSystemMXBean os = (OperatingSystemMXBean)bean;
|
||||
long physicalMemorySize = os.getTotalPhysicalMemorySize() / (1024 * 1024);
|
||||
System.out.println("System memory size: " + physicalMemorySize + "M");
|
||||
// when we can get system memory size, and it's larger than 2G,
|
||||
// then we enable large array size test below,
|
||||
// else disable large array size test below.
|
||||
if (physicalMemorySize > (2 * 1024)) {
|
||||
arraySizeCollection = new int[]{
|
||||
SMALL_ARRAY_SIZE,
|
||||
THRESHOLD_ARRAY_SIZE,
|
||||
MEDIUM_ARRAY_SIZE,
|
||||
LARGE_ARRAY_SIZE
|
||||
};
|
||||
System.out.println("System memory is large enough, add large array size test");
|
||||
return;
|
||||
}
|
||||
}
|
||||
arraySizeCollection = new int[]{
|
||||
SMALL_ARRAY_SIZE,
|
||||
THRESHOLD_ARRAY_SIZE,
|
||||
MEDIUM_ARRAY_SIZE
|
||||
};
|
||||
System.out.println("System memory is not large enough, remove large array size test");
|
||||
}
|
||||
|
||||
@DataProvider(name = "intSet")
|
||||
public static Object[][] intSet(){
|
||||
@ -96,10 +125,10 @@ public class ParallelPrefix {
|
||||
|
||||
private static <T, OPS> Object[][] genericData(Function<Integer, T> generateFunc, OPS[] ops) {
|
||||
//test arrays which size is equals n-1, n, n+1, test random data
|
||||
Object[][] data = new Object[ARRAY_SIZE_COLLECTION.length * 3 * ops.length][4];
|
||||
for(int n = 0; n < ARRAY_SIZE_COLLECTION.length; n++ ) {
|
||||
Object[][] data = new Object[arraySizeCollection.length * 3 * ops.length][4];
|
||||
for(int n = 0; n < arraySizeCollection.length; n++ ) {
|
||||
for(int testValue = -1 ; testValue <= 1; testValue++) {
|
||||
int array_size = ARRAY_SIZE_COLLECTION[n] + testValue;
|
||||
int array_size = arraySizeCollection[n] + testValue;
|
||||
for(int opsN = 0; opsN < ops.length; opsN++) {
|
||||
int index = n * 3 * ops.length + (testValue + 1) * ops.length + opsN;
|
||||
data[index][0] = generateFunc.apply(array_size);
|
Loading…
x
Reference in New Issue
Block a user