Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8058897

Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2
    • 9
    • 9
    • hotspot
    • b48
    • Verified

    Backports

      Description

        -XX:MallocMaxTestWords is used to limit amount of native memory available to VM.

        Yes, indeed. If I run vm with -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=16m

        Unsafe.allocateMemory(1G) will cause OOM, as expected.

        But, reallocate will not...

        address = Unsafe.allocateMemory(100); // ok
        address = Unsafe.reallocateMemory(address, 1G); // no exception!!!
        address = Unsafe.allocateMemory(1G); // OOM - ok

        attached ReallocatedTest - demonstrates the problem:

        # java -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=16m ReallocateTest
        Allocating: 100
          successful: 9415472
        Re-allocating: 1000000000
          successful: 9440064
        Memory reallocated... OOM is expected here
        Allocating: 1000000000
        OOM: java.lang.OutOfMemoryError
        Test failed



        Attachments

          Issue Links

            Activity

              People

                ctornqvi Christian Tornqvist
                dfazunen Dmitry Fazunenko (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: