Hi Guys,

I am a relative new member in this forum , My name is Javin Paul and I am Java programmer. I have question related to garbage collection in Java

Does garbage collection occurs in PERM Area of Java Heap ?

As per my knowledge PERM area is used to store meta data about classes, methods , variable etc also String Pool created in PERM area of heap so I believe garbage collection does not occur in this place but just wanted to know what do you guys think of it ?


Does garbage collection occurs in PERM Area of Java Heap ?

AFAIK, yes.

This aspect doesn't come into play a lot when doing regular development and using already existing libraries but becomes apparent when you implement custom classloaders and manage class loading dynamically.

One e.g. would be Tomcat servlet container. Let's assume that Tomcat creates a separate "classloader" for each web application deployed. If out of the many running web apps if one of the web apps is stopped, the corresponding classloader goes out of scope along with the objects/classes created/loaded using that classloader. If now, for some reason a permagen GC is triggered, the classes along with the classloader would now be garbage collected. If you run the JVM with the -verbose:class switch, this can be easily confirmed by the log message "Unloading class somepkg.xxx".

Edited 5 Years Ago by ~s.o.s~: n/a

:) I'm looking forward to seeing more great stuff from **your** blog posts.

Thanks , you do have a point here that classloader which goes out of the scope will be garbage collected.

This question has already been answered. Start a new discussion instead.