Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-5844

ArrayUtil.grow should not pretend you can actually allocate array[Integer.MAX_VALUE]

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.9.1, 4.10, 6.0
    • core/other
    • None
    • New

    Description

      Today if the growth it wants would exceed Integer.MAX_VALUE, it returns Integer.MAX_VALUE, but you can't actually allocate arrays this large; the actual limit is JVM dependent and varies across JVMs ...

      It would be nice if we could somehow "introspect" the JVM to find out what its actual limit is and use that. http://stackoverflow.com/questions/3038392/do-java-arrays-have-a-maximum-size seems to imply that using Integer.MAX_VALUE - 8 may be "safe" (it's what ArrayList.java apparently uses).

      Attachments

        1. LUCENE-5844.patch
          3 kB
          Michael McCandless
        2. LUCENE-5844.patch
          5 kB
          Michael McCandless

        Activity

          People

            mikemccand Michael McCandless
            mikemccand Michael McCandless
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: