java.lang.OutOfMemoryError: PermGen space [closed]
Solution 1:
If you are getting the questioned error in the secondary Eclipse Application, adding -XX:MaxPermSize=512m
in ini
won't help. You need to go into debug or run configuration->arguments
and add that piece in VM arguments.I also increased others memory limits so:
-Dosgi.requiredJavaVersion=1.5 -Xms120m -Xmx2048m -XX:MaxPermSize=1024m
It helped.
Edit. After some experiments I've found, that Eclipse does take memory limits from the ini file. But... it does it only once, at the creation of a new workspace. Parameters from -vmarg in eclipse.ini create the default VM parameters line. So, if you are working on the existing workspace, change debug or run configuration. But change eclipse.ini, too, for better future.
Solution 2:
Your project eats a lot of memory. Give Eclipse more memory to work with. Edit eclipse.ini
to modify or add the following lines below -vmargs
.
-Xms256m -Xmx512m -XX:MaxPermSize=512m
Assuming you've at least 2GB of RAM.
See also:
- Editing
eclipse.ini
Solution 3:
- Click on Server instance.
- Open Launch Configurations.
- Increase memory to JVM,in argument tab.
-Xms64m -Xmx256m
See below images:
Solution 4:
Java applications are allowed to use only limited amount of memory. The exact amount of memory your particular application can use is specified during the application startup. To make things more complex, the Java memory is separated to different regions, one of which being called PermGen.
Size of all those regions is set during the JVM launch. If you do not explicitly set the sizes, platform-specific defaults will be used.
So – the java.lang.OutOfMemoryError: PermGen space
message indicates that the Permanent Size area in memory is exhausted.
This specific area called PemGen is a dedicated region where Java classes are loaded and stored. This consists of the following:
- Names of the classes
- Fields of the class
- Methods of a class with the bytecode of the methods
- Constant pool information
- Object arrays and type arrays associated with a class
- Just In Time compiler optimizations
That’s pretty much it. Some more bits and pieces, but it does not impact the actual memory consumption by more than few percent. All these are allocated in the permanent generation and stay in the permanent generation.
As you can see, the permanent generation size requirements depend both upon the number of classes loaded as well as the size of such class declarations. So it is easy to see the main cause for such error: either too many classes or too big classes are being loaded to the permanent generation.
Quick fix for symptoms is easy - if we have exhausted the PermGen area in the heap, we need to increase its size. This solution is indeed helpful if just have not given your JVM enough elbow room. So alter your application launch configuration and add (or increase if present) the following:
-XX:MaxPermSize=512m