On 12/7/17 5:39 AM, 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);
This looks okay. It seems unlikely that hundreds of native libraries
will be loaded, then unloaded, and the backing array being a memory
concern.
Yup, it's not a big concern. I believe the number of elements in this
deque is typically very small number. This deque is used to keep the
native libraries are being loaded and its context used by JNI FindClass
when called from JNI_OnLoad.
Mandy