hotspot/test/runtime/NMT/UnsafeMallocLimit2.java
author thartmann
Tue, 28 Oct 2014 16:44:39 +0100
changeset 27431 5f970b31939c
parent 26925 c77fdcf78eeb
permissions -rw-r--r--
8062250: [TESTBUG] compiler/codecache/CheckSegmentedCodeCache.java fails after CodeCacheMinimumFreeSpace removal Summary: Adapted calculation of minimum code cache size after CodeCacheMinimumFreeSpace was removed by JDK-8046809. Reviewed-by: kvn, anoll
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26925
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
     1
/*
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
     4
 *
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
     8
 *
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    13
 * accompanied this code).
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    14
 *
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    18
 *
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    21
 * questions.
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    22
 */
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    23
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    24
/*
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    25
 * @test
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    26
 * @bug 8058818
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    27
 * @library /testlibrary
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    28
 * @build UnsafeMallocLimit2
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    29
 * @run main/othervm -Xmx32m -XX:NativeMemoryTracking=off UnsafeMallocLimit2
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    30
 */
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    31
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    32
import com.oracle.java.testlibrary.*;
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    33
import sun.misc.Unsafe;
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    34
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    35
public class UnsafeMallocLimit2 {
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    36
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    37
    public static void main(String args[]) throws Exception {
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    38
        if (Platform.is32bit()) {
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    39
            Unsafe unsafe = Utils.getUnsafe();
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    40
            try {
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    41
                // Allocate greater than MALLOC_MAX and likely won't fail to allocate,
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    42
                // so it hits the NMT code that asserted.
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    43
                // Test that this doesn't cause an assertion with NMT off.
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    44
                // The option above overrides if all the tests are run with NMT on.
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    45
                unsafe.allocateMemory(0x40000000);
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    46
                System.out.println("Allocation succeeded");
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    47
            } catch (OutOfMemoryError e) {
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    48
                System.out.println("Allocation failed");
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    49
            }
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    50
        } else {
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    51
            System.out.println("Test only valid on 32-bit platforms");
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    52
        }
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    53
    }
c77fdcf78eeb 8058818: Allocation of more then 1G of memory using Unsafe.allocateMemory is still causing a fatal error on 32bit platforms
coleenp
parents:
diff changeset
    54
}