Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the PermGen space ever decreased?

Tags:

java

hibernate

I would like to know if the JVM normally unloads classes in order to decrease the PermGen space. So here my questions:

  1. Do Java classes ever get unloaded by default from a JVM?
  2. Does closing a Jar classloader unloads all the loaded classes from that jar?
  3. What commands/ways should be used to allow the unloading of classes?

FYI, I did try some of the solutions on the web but none of them answered my questions. (for example: What does JVM flag CMSClassUnloadingEnabled actually do?)

PS: I am referring to Java 6 + hibernate (The class loading is handled by hibernate)

like image 326
Adel Boutros Avatar asked Jul 15 '13 10:07

Adel Boutros


People also ask

How can you control size of PermGen space?

Open eclipse. ini file, it is located in root eclipse directory. there you can change -Xms and -Xmx parameter to change permgen size. There you can change -XX:PermSize and -XX:MaxPermSize.

Why does Java 8 remove PermGen space?

In the place of PermGen, a new feature called Meta Space has been introduced. MetaSpace grows automatically by default. Here, the garbage collection is automatically triggered when the class metadata usage reaches its maximum metaspace size. It is removed from java 8.

What is the replacement of PermGen space in Java 8?

Simply put, Metaspace is a new memory space – starting from the Java 8 version; it has replaced the older PermGen memory space.

What is PermGen space?

lang. OutOfMemoryError: PermGen Space is a runtime error in Java which occurs when the permanent generation (PermGen) area in memory is exhausted. The PermGen area of the Java heap is used to store metadata such as class declarations, methods and object arrays.


1 Answers

The only way to get rid of loaded classes is to allow JVM to GC the class loader which loaded these classes by eliminating all references to this class loader. This is what happens in web servers when we undeploy a webapp.

like image 110
Evgeniy Dorofeev Avatar answered Nov 15 '22 17:11

Evgeniy Dorofeev