Thursday, July 2, 2009

Solution to "java.lang.OutOfMemoryError: PermGen space"

I was trying to debug Eclipse WTP with Eclipse for RCP to locate the code causing the bug I mentioned in the previous post. When the break point inserted was hit, it returned such as error "java.lang.OutOfMemoryError: PermGen space" in the console window of Eclipse for RCP.

I googled the error message for solutions, and find the following link, http://www.freshblurbs.com/explaining-java-lang-outofmemoryerror-permgen-space, has a detailed explanation on what exactly this error is and the cause of the error.

The easiest way to solve this problem is to increase the maximum size of PermGen space. You can change the size of PermGen space by either editing eclipse.ini of Eclipse Web Tools Platform or specifying the JVM memory settings of Eclipse for RCP.

To change the maximum size of PermGen space through eclipse.ini of Eclipse Web Tools Platform, navigate to the folder where WTP is installed. Then you will find a file called "eclipse.ini" similar to this:



What you need to do is to add the following line to the end of the file:
-XX:MaxPermSize=128m (not necessarily 128m, default is 64m)

To change the maximum size of PermGen space on Eclipse memory settings of JVM, Click on Run/Debug Configurations... under Run menu. Then the Run/Debug Configurations... window pops up. On the left panel of Run/Debug Configurations... window, expand "Eclipse Application" and select new configuration. (If you do not see any configuration, create a new one by right clicking on "Eclipse Application" and select "New" from the context menu). On the right panel of Run/Debug Configurations... window, click on the argument tab, put the following line into the text box for "VMarguments":
-XX:MaxPermSize=128m

Click on Run/Debug at the bottom.

8 comments: