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

Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b48
    • Verification:
      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

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

                  Dates

                  Created:
                  Updated:
                  Resolved: