hotspot/test/runtime/NMT/UnsafeMallocLimit.java
author thartmann
Tue, 28 Oct 2014 16:44:39 +0100
changeset 27431 5f970b31939c
parent 26561 e104c9397ca1
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:
26561
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
     1
/*
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
     4
 *
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
     8
 *
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    13
 * accompanied this code).
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    14
 *
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    18
 *
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    21
 * questions.
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    22
 */
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    23
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    24
/*
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    25
 * @test
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    26
 * @bug 8055289
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    27
 * @library /testlibrary
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    28
 * @build UnsafeMallocLimit
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    29
 * @run main/othervm -Xmx32m -XX:NativeMemoryTracking=summary UnsafeMallocLimit
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    30
 */
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    31
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    32
import com.oracle.java.testlibrary.*;
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    33
import sun.misc.Unsafe;
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    34
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    35
public class UnsafeMallocLimit {
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    36
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    37
    public static void main(String args[]) throws Exception {
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    38
        if (Platform.is32bit()) {
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    39
            Unsafe unsafe = Utils.getUnsafe();
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    40
            try {
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    41
                unsafe.allocateMemory(1 << 30);
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    42
                throw new RuntimeException("Did not get expected OOME");
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    43
            } catch (OutOfMemoryError e) {
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    44
                // Expected exception
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    45
            }
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    46
        } else {
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    47
            System.out.println("Test only valid on 32-bit platforms");
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    48
        }
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    49
    }
e104c9397ca1 8055289: Internal Error: mallocTracker.cpp:146 fatal error: Should not use malloc for big memory block, use virtual memory instead
zgu
parents:
diff changeset
    50
}