0

I'm using eclipse with spring mvc, spring data jpa + queryDSL and apache tomcat server8 and sometimes not always but offten when i save my java classes ctrl+s tomcat restart and i get OutOfMemoryError: PermGen space

Cœur
  • 37,241
  • 25
  • 195
  • 267
Hayi
  • 6,972
  • 26
  • 80
  • 139

4 Answers4

0

in eclipse you can turn off auto deploy after saving that way you don't chain deploy when saving. perm gen memory is used when deploying, so increasing it will only cause it to happen again after several more saves

j.con
  • 879
  • 7
  • 19
  • where can i check this property ? and if i turn off this property the changes i made to my java classes will be known in apache ? – Hayi Jul 15 '14 at 18:07
  • i am not sure how to do it in eclipse, i use netbeans (but im sure if you right click the .EAR/.EJB/.WAR and chose properties you will find it, all 3 need to be unchecked in netbeans). and yes apache will know of it, it gets saved in the project.properties file – j.con Jul 15 '14 at 18:16
  • I try it and tomcat didn't restart but the changes didn't apply when i open my browser – Hayi Jul 15 '14 at 18:26
  • because if you have auto deploy after saving disabled then you need to redeploy manually. it may seem like it causes more work (extra button clicks) but it has its trade offs, and imo since i work with dozens of .EARs open at a time, it is much more efficient performance wise, else netbeans/eclipse would always be deploying since i use ctr-s a lot – j.con Jul 15 '14 at 18:30
  • thanks and now in this case if i deploy manually the `OutOfMemoryError: PermGen space` will not occurs ? – Hayi Jul 15 '14 at 18:33
  • unfortunately i turn off the auto deploy i make some changes and when i publish to server it give the `OutOfMemoryError: PermGen space` error :-( – Hayi Jul 15 '14 at 18:36
  • it will occur, but a lot less frequently. that error is something you can not get around because tomcat/glassfish have memory leaks. you can increase the pergen space (no more than 1gb, i've seen weird stuff happen) but no less than 256mb. restarting the server is how you clear up the memory – j.con Jul 15 '14 at 18:37
  • btw if you are just making changes in the `.WAR's .xhtml` then a page refresh is all that is needed and not a clean/build/deploy – j.con Jul 15 '14 at 18:38
  • no i change my controller.java not just my jsp .. because jsp don't need a deploy – Hayi Jul 15 '14 at 18:41
  • also where can i increase the pergen space ? – Hayi Jul 15 '14 at 18:45
0
Clean Your Tomcat server and restart it 
or

**Modify Your Pergem Size :**
Open the Configuration file in the eclipse directory forlder. for eg. C:\eclipse-jee-galileo-SR2-win32\eclipse
just add -XX:MaxPermSize=256m command below the -vmargs line. Change value of -XX:MaxPermSize as per your requirement. If your project is big you should use 512m or 1024m. I'm using 256m in my project.

Now your eclipse.ini file should look like this

-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-product
org.eclipse.epp.package.jee.product
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256M
-vmargs
-XX:MaxPermSize=512m 
-Dosgi.requiredJavaVersion=1.5
-Xms512m
-Xmx1024m


For More Information see this 
http://wiki.eclipse.org/Eclipse.ini

U can watch here 
http://stackoverflow.com/questions/88235/dealing-with-java-lang-outofmemoryerror-permgen-space-error
0

i follow the dcevm solution and it work better it allows only changing method bodies without restarting apache tomcat.

Hayi
  • 6,972
  • 26
  • 80
  • 139
-1
  1. Give tomcat more memory. Use the following vm args: -Xmx1600m -Xms1600m -XX:MaxPermSize=512m (might be a bit of an overkill, modify the values to your taste)

  2. Tomcat is infamous for memory leaks when reloading web applications. Nothing you can do about this one other than what's described in step 1.

dimoniy
  • 5,820
  • 2
  • 24
  • 22