If I use String.intern() to improve performance as I can use \"==\" to compare interned string, will I run into garbage collection issues? How does the garbage collection me
This article provides the full answer.
In java 6 the string pool resides in the PermGen, since java 7 the string pool resides in the heap memory.
Manually interned strings will be garbage-collected.
String literals will be only garbage collected if the class that defines them is unloaded.
The string pool is a HashMap with fixed size which was small in java 6 and early versions of java 7, but increased to 60013 since java 7u40.
It can be changed with -XX:StringTableSize=