I am wondering how the values are removed from the row pool?
suppose:
String a = "ABC"; // has a reference of string-pool String b = new String("ABC"); // has a heap reference b = null; a = null;
In the case of the GC, “ABC” is collected from the heap, but “ABC” is still in the pool (because its in permGen and GC will not affect it).
If we add values such as:
String c = "ABC";
What I want to know:
- Does the pool delete values that are not referenced? If not, it means that the pool has unnecessary memory.
- What is the point when the JVM uses the pool?
- When can this be a performance risk?
source share