Review Request: JDK-8193159: Reduce the number of classes loaded due to NativeLibrary

Claes Redestad claes.redestad at oracle.com
Thu Dec 7 13:50:30 UTC 2017



On 2017-12-07 14:39, Alan Bateman wrote:
>
>
> On 07/12/2017 05:04, mandy chung wrote:
>>
>>
>> On 12/6/17 6:08 PM, Martin Buchholz wrote:
>>> Google decided that LinkedList is almost never the best choice, so 
>>> any use of LinkedList is discouraged.
>>>
>>> ArrayDeque's backing array never shrinks, so you might want to give 
>>> it an explicit initial size.
>>>
>>
>> The initial size is 16 which is okay.  I can make it smaller instead:
>>
>> -        static Deque<NativeLibrary> nativeLibraryContext = new 
>> LinkedList<>();
>> +        static Deque<NativeLibrary> nativeLibraryContext = new 
>> ArrayDeque<>(8);

+1

> This looks okay. It seems unlikely that hundreds of native libraries 
> will be loaded, then unloaded, and the backing array being a memory 
> concern.

It also needs to load said hundreds of native libraries in parallel for 
this context queue to grow in the first place, right?

So I'm not concerned, but on that tangent I have been wondering for some 
time why ArrayDeque doesn't have a
trimToSize method like ArrayList does. Theoretically it'd be nice to 
have some means to allow periodically taking a
look at persistent queues like this one and trim the backing arrays down 
if they ever outgrow their purpose. I guess
it's just never become a real problem...

/Claes



More information about the core-libs-dev mailing list