PermGen Space Exception

I am using JAVA 5 (32 bit) for my application running on JBoss. But it works fine only for 32-bit. When we deploy it on 64-bit java5, it throws an exception

"java.lang.OutOfMemoryError: PermGen space" exception 

Is a fix required? Is a code change required?

Thanks in advance.

+4
source share
4 answers

I have the same span when I launch my web application under tomcat or jetty. Genome read-only memory is used to load classes, and the idea is that "Classes load once and for all." Since I use quite a few Spring libraries and frameworks, this memory fills up very quickly when I redeploy the web application several times without reloading the servlet container.

I found that increasing the maximum continuous generation is not enough. You also need to allow garbage collection to remove unused classes at runtime, otherwise it will be full and throw a PermGen space exception. Here are the JVM options I added for my servlet containers,

 -XX:PermSize=128m -XX:MaxPermSize=256m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled 

-XX:MaxPermSize used to set the maximum value of continuous generation. This should be larger than the default size.

-XX:+CMSClassUnloadingEnabled This option is used to allow the JVM to unload the class at runtime. By default, class unloading is disabled. For Java 5, please read.

-XX:+UseConcMarkSweepGC , for the class loading option to work, this parameter must also be set ( ref )

In addition, you should consider upgrading the JVM version. Java 5 is too old.

+7
source

64-bit Java has twice as many pointers as 32-bit. Since most of your objects are made up of pointers (links to other objects), you need significantly more memory to run. You are launching the 64-bit version because your application requires, in the first place, more than 4 GB, right? If you do not, you will be better off with a 32-bit JVM.

Play with -XX:MaxPermSize= at server startup.

+3
source

Is a fix required?

Yes, using the 64-bit version of Java 6 or 7, which uses 32-bit links by default. Java 5.0 uses 64-bit links. I do not think this will be added in Java 5.0, since it has not been supported for almost two years. (You can pay to support his BTW)

In the Sun / Oracle JVM, objects are aligned by 8 bytes. The JVM uses this fact to use 32-bit references for a 32 GB memory address. (8 * 4G). With direct memory and memory with memory, you can use more than 32 GB.

+2
source

Create one environment variable with the following parameters / values:

 varible name = JAVA_OPTS variable value = -Xmx1000M -XX:MaxPermSize=512m 
0
source

All Articles