I'm curious, how values from string-pool get removed?
suppose:
String a = "ABC"; // has reference of string-pool
String b = new String("ABC"); // has heap reference
b = null;
a= null;
In case of GC, "ABC" from heap get collected.But "ABC" still there in pool(because its in permGen and GC would not effect it).
if we keep adding values like
String c = "ABC"; // pointing to 'ABC' in pool.
for(int i=0; i< 10000; i++) {
c = ""+i; // each iteration add new value in pool. and pervious values has no pointer
}
I want to know, will pool remove unreferred values? if not, it's mean pool eating up unnecessary memory. than what's a point, jvm is using pool? when it could be a performance risk?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire