On Wed, 13 Nov 2024 19:00:34 GMT, Aleksey Shipilev <sh...@openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/ref/CleanerImpl.java line 290:
>> 
>>> 288:                 list.remove(lastIdx);
>>> 289: 
>>> 290:                 // Capacity control: trim the backing storage if it 
>>> looks like
>> 
>> I think we need to set maxIdx to lastIdx - 1 here.  Otherwise, we'll never 
>> trim back the storage.  maxIdx can only increase in insert() as currently 
>> implemented.
>
> Right, d'oh. The unavailability of `ArrayList.capacity()` is what gets us in 
> this mess. I'll try to rewrite to just plain arrays.

I pushed the array-based implementation, but ran out of time to properly test 
it. I'll circle back to it tomorrow. Review if you can, but it will probably 
have some touchups later.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/22043#discussion_r1841138042

Reply via email to