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

Incorrect documentation for OutOfMemoryError: Requested array size exceeds VM limit

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 19
    • 17, 18
    • docs

        In the Troubleshooting Guide, the documentation for OOME contained errors. These were fixed in JDK 16 by JDK-8254804. The JDK 16 version of the "Understand the OutOfMemoryError Exception" section has the following, correct text:

        https://docs.oracle.com/en/java/javase/16/troubleshoot/troubleshoot-memory-leaks.html#GUID-19F6D28E-75A1-4480-9879-D0932B2F305B

        ==========
        Exception in thread thread_name: java.lang.OutOfMemoryError: Requested array size exceeds VM limit

            Cause: The detail message "Requested array size exceeds VM limit" indicates that the application (or APIs used by that application) attempted to allocate an array with a size larger than the VM implementation limit, irrespective of how much heap size is available.

            Action: Ensure that your application (or APIs used by that application) allocates an array with a size less than the VM implementation limit.
        ==========

        However, in the JDK 17 and JDK 18 versions of this chapter, the incorrect text from the releases previous to JDK 16 has reappeared. This incorrect text now appears in the "The java.lang.OutOfMemoryError Error" section:

        https://docs.oracle.com/en/java/javase/18/troubleshoot/troubleshooting-memory-leaks.html#GUID-19F6D28E-75A1-4480-9879-D0932B2F305B

        ==========
        Detail Message: Requested array size exceeds VM limit

            Cause: The detail message Requested array size exceeds VM limit indicates that the application (or APIs used by that application) attempted to allocate an array with a size larger than the heap size (the virtual machine (VM) limit). For example, if an application attempts to allocate an array of 512 MB, but the maximum heap size is 256 MB, then a java.lang.OutOfMemoryError error will be thrown with the detail message Requested array size exceeds VM limit.

            Action: Usually the problem is either a configuration issue (heap size too small) or a bug that results from an application attempting to create a huge array (for example, when the number of elements in the array is computed using an algorithm that produces in an incorrect size).
        ==========

        Corrections made to this material in JDK 16 need to be re-applied to the current version.

              rgallard Raymond Gallardo
              smarks Stuart Marks
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: