Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat 7 Spring App IntelliJ IDEA 10.5 OutOfMemoryError: PermGen space

Not sure who is responsible for this error:

Exception in thread "main" java.lang.OutOfMemoryError: PermGen space

This error occurs whey I try to run my spring web app in Debug mode from the IntelliJ IDEA 10.5 (my project is maven format project).

When running the same application from the standalone Tomcat 7 Web server (put war into webapps folder) it works fine. Also from mvn clean install t7:run-forked application also works fine.

My app is Spring JPA application using Hibernate as JPA provider, c3p0 is used for connection pooling (switched to it from bonecp, thought that the bonecp was the cause of this error, but it is still reproducible with c3p0 too), Spring TomcatInstrumentationLoading is used for JPA support on Tomcat.

My OS is Debian, Linux.

like image 889
Aliaksandr Kazlou Avatar asked Dec 30 '11 09:12

Aliaksandr Kazlou


People also ask

How to fix PermGen space error in Tomcat?

By default, Tomcat is assigned a very little PermGen memory for the running process. To fix it, increase the PermGen memory settings by using the following Java VM options. -XX:PermSize<size> - Set initial PermGen Size. -XX:MaxPermSize<size> - Set the maximum PermGen Size.

How can I increase my PermGen size?

The default maximum memory size for 32-bit JVM is 64 MB and 82 MB for the 64-bit version. However, we can change the default size with the JVM options: -XX:PermSize=[size] is the initial or minimum size of the PermGen space. -XX:MaxPermSize=[size] is the maximum size.

What causes PermGen space error?

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.


2 Answers

This should be enough to make it work:

-XX:MaxPermSize=256m

VM options field is set in the Tomcat Run/Debug configuration to

-XX:MaxPermSize=256m

like image 84
CrazyCoder Avatar answered Sep 19 '22 15:09

CrazyCoder


Set VM arguments to allocate more space for your program

like

-Xms128m -Xmx8192m -XX:PermSize=128m -XX:MaxPermSize=256m 
like image 40
Bala Avatar answered Sep 20 '22 15:09

Bala