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

Standardize dynamic array growth factor

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • tbd
    • core-libs

      ByteArrayOutputStream (along with some other classes) uses an exponential growth factor of 2 for its internal buffer, i.e. it doubles in size when it exceeds its existing capacity.

      Other JDK classes use a factor of 1.5, e.g. ArrayList, StringLatin1 or 2 separate values depending on the absolute size (PriorityBlockingQueue).

      Should we standardize on one value?

      I haven't found any discussion or reasoning on the two different values specifically in JDK, though there's plenty of discussion externally (e.g. https://en.wikipedia.org/wiki/Dynamic_array#Growth_factor).

            bpb Brian Burkhalter
            ogillespie Oli Gillespie
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: