I was reading about the memory management in java 8.It talks of Meta space but it does not talk of String pool.Can you please suggest me what happened to String pool in java 8.
Thanks in Advance. Rajesh
The change has been done on java7 itself that the constant pool has been moved to typical heap space from permgen space(still the pool behaviour is same) where as permgen space completely removed in Java 8. Metaspace is nothing to do with constant pool specially, it is generic for all objects.
Nothing is changed as in the concept of string pool but from java 7 onward string pool is created in heap memory instead of permgen. The advantage of doing this is the unreferenced variable in string pool will be taken care by JVM garbage collector. So it will improve over space.
www.oracle.com/technetwork/java/javase/8-whats-new-2157071.html
here is the java 8 release notes nothing seem to be about String.intern . Here is little difference : The default value of -XX:StringTableSize parameter is 1009 in Java 6 and Java 7 until Java7u40. It was increased to 60013 in Java 7u40 (same value is used in Java 8 as well). It's subtle but gives a big performance advantage. check this blog post for more info: http://java-performance.info/string-intern-in-java-6-7-8/
When we create a String object using the new() operator, it always creates a new object in heap memory. On the other hand, if we create an object using String literal syntax, if it already exists the Java compiler will simply return a reference to its memory address from the String pool, without allocating additional memory. Otherwise, it will create a new String object and put in the string pool for future re-use.
for more info read this :
https://www.baeldung.com/java-string-pool
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