This article discusses the implementation of String.intern()
. In Java 6 and 7, the implementation used a fixed size (1009) hashtable so as the number entries grew, the performance became O(n). The fixed size can be changed using -XX:StringTableSize=N
. Apparently, in Java8 the default size is larger but issue remains.