On Fri, 10 Jul 2026 11:35:35 GMT, John Hendrikx <[email protected]> wrote:
>> modules/javafx.base/src/main/java/com/sun/javafx/binding/ArrayManager.java >> line 347: >> >>> 345: * When the minimum size of the array is 3 (MINIMUM_SIZE), >>> 346: * then the resizing algorithm used here always uses specific >>> 347: * sizes: 3, 7, 13, 22, 36, etc... >> >> question: wouldn't it use more memory than necessary if the underlying >> memory allocation uses power of two blocks? wouldn't it make more sense to >> use power of two sized blocks? > > This mirrors roughly how `ArrayList` does this (it also increases by about > 50% each time) instead of doubling (this has an overhead of about 25% per > element on average, while doubling would have one of about 50% on average). > The underlying allocation for the array memory may do alignment rounding, but > it is not forcing power of two sizes. > > The reason the resizing algorithm is super deterministic is because we also > shrink the arrays when there is no need for the space anymore (but we want to > avoid a shrink->grow->shrink scenario on boundaries, so there is some overlap > here). the growing and shrinking is fine, but 3, 7, 13 might be suboptimal since everything revolves around powers of 2. ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/1081#discussion_r3559816164
