Can the Perm Heap shrink?
I am running JDK 1.4.2 and I was wondering, can the "Perm Heap" can actually shrink or not?
If not in the JDK 1.4.2 is it available later?
If so, then what determines if the class info is no longer referenced and therefore can be garbage collected. Is it after all of the objects of that type no longer exist in the tenured heap?
> I am running JDK 1.4.2 and I was wondering, can the
> "Perm Heap" can actually shrink or not?
>
Yes, for example when using custom classloaders. When some classloader is collected then classes loaded by it wil be unloaded.
> If not in the JDK 1.4.2 is it available later?
>
> If so, then what determines if the class info is no
> longer referenced and therefore can be garbage
> collected. Is it after all of the objects of that
> type no longer exist in the tenured heap?
> I am running JDK 1.4.2 and I was wondering, can the
> "Perm Heap" can actually shrink or not?
Yes.
> If not in the JDK 1.4.2 is it available later?
>
> If so, then what determines if the class info is no
> longer referenced and therefore can be garbage
> collected. Is it after all of the objects of that
> type no longer exist in the tenured heap?
A class is unloaded from the perm gen only when the ClassLoader object that loaded the class becomes unreachable. The ClassLoader becomes unreachable when there are no more live instances of *any* class loaded by that ClassLoader in the heap.
In effect, this means you have to use your own ClassLoader to allow your classes to be unloaded. The "system class loader" that loads the main class survives for the lifetime of the JVM, and so no classes that it loads will be unloaded.