String pool is created in PermGen area or Object area of Heap

10,566

Solution 1

The move to Metaspace was necessary since the PermGen was really hard to tune.

Also, it was difficult to size the PermGen since the size depended on a lot of factors such as the total number of classes, the size of the constant pools, size of methods, etc.

Additionally, each garbage collector in HotSpot needed specialized code for dealing with metadata in the PermGen. Detaching metadata from PermGen not only allows the seamless management of Metaspace, but also allows for improvements such as simplification of full garbage collections and future concurrent de-allocation of class metadata.

Solution 2

In Java 6 days all interned strings were stored in the PermGen – the fixed size part of heap mainly used for storing loaded classes and string pool. Besides explicitly interned strings, PermGen string pool also contained all literal strings earlier used in your program.

The biggest issue with string pool in Java 6 was its location – the PermGen. PermGen has a fixed size and can not be expanded at runtime. You can set it using -XX:MaxPermSize=N option.

engineers made an extremely important change to the string pooling logic in Java 7 – the string pool was relocated to the heap. It means that you are no longer limited by a separate fixed size memory area. All strings are now located in the heap, as most of other ordinary objects, which allows you to manage only the heap size while tuning your application.

Ref : http://java-performance.info/string-intern-in-java-6-7-8/

Share:
10,566

Related videos on Youtube

Andy897
Author by

Andy897

Updated on July 28, 2022

Comments

  • Andy897
    Andy897 over 1 year

    HERE, author is saying that

    3) String pool is created in PermGen area of Heap, garbage collection can occur in perm space but depends upon JVM to JVM. By the way from JDK 1.7 update, String pool is moved to heap area where objects are created.

    Is there any specific reason why is it done ? I am not able to find any online. And what are the implications ?

    • meskobalazs
      meskobalazs almost 9 years
      Not an answer for this, but could be relevant: from Java 8, there is no longer a PermGen space.