While going through this article about String pool and its changes over the years, I came across the following statement:
Prior to Java 7u40, the default pool size was 1009 buckets but this value was subject to a few changes in more recent Java versions. To be precise, the default pool size from Java 7u40 until Java 11 was 60013 and now it increased to 65536.
So, what are buckets in String pool? How are these comparable to the number of interned Strings? Is the concept similar to buckets in hashmaps?
So, what are buckets in String pool?
The String pool is basically a hash table. A hash table contains buckets or slots.
How are these comparable to the number of interned Strings?
It's implementation-defined (JVM-specific) and depends on how many entries a single bucket stores. Ideally, one bucket keeps one entry.
Is the concept similar to buckets in hashmaps?
Yes, it's the same idea.
Why is the default pool size growing? (my question)
The more buckets are allocated, the lower the load factor gets, which positively affects performance. I guess the initial number of entries occupied in the table grows, so it's important to keep the load factor updated (at least at the same level).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With