Friday 15 July 2016

Difference in String pool between Java 6 and 7

String pool in Java is a pool of String literals and interned Strings in JVM for efficient use of String object. Since String is immutable in Java, it makes sense to cache and shares them in JVM. The String pool has gone through an important change in Java 7 release when it was relocated from PermGen space to heap space. Till Java 1.6, interned String and literals are stored in the PermGen space of JVM memory, which was a fixed size area for storing class metadata. The biggest issue of having String pool in PermGen is the small and fixed size of PermGen space. In some JVM it ranges from 32M to 96M, which is quite small for a large program. Since String is extensively used in both small and large Java application, Java designers thought String pool is the best way optimize the use of String object in Java.
Read more »

No comments:

Post a Comment