Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OutOfMemoryError: PermGen space

 
Jeppe Mariager
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,

First off, sorry if this has been answered before, i did some searching, but didnt find much i knew how to do.

I'm a totl newbie in the Java world, but my company has recently purchased a new CMS coded in Java, and since i'm a webdeveloper, i got the task of moving our sites to the new system. When i develop on my laptop, i often run into the OutOfMemoryError: PermGen space error. I figured that it's because my java stuff doesnt get as much memory as it should - But my question is, how do i increase this? I checked my memory usage at the time before and after the problem, and i use around 1.3 gig of 3 gig RAM, so i figure that it should be possible to kick some more resources after the java programs.

Here's my current JAVA_OPS from jboss run.conf:

JAVA_OPTS="-server -Xms128m -Xmx1024m -XX :p ermSize=64m -XX:MaxPermSize=512m -Dcom.sun.management.jmxremote -Djava.util.logging.config.file=/usr/local/jboss/server/default/conf/logging.properties"

I figure that it's something in there that needs tweaking, but i'm not sure what exactly?

Thanks a lot for your time if you can help me, it's really appreciated. I'm really starting to like Java, and if i can just get this error fixed, i'll hopefully be flying in no time
[ May 09, 2008: Message edited by: Jeppe Mariager ]
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The java.lang.OutOfMemoryError: PermGen space failure is often ran into during development when frequently deploying/undeploying/re-deploying application builds. Increasing the value of -XX:MaxPermSize for the server VM is your best bet at a timely working-around for the issue, as pinpointing the exact cause is usually very difficult.
[ May 09, 2008: Message edited by: Jelle Klap ]
 
Akshay Kiran
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Jeppe Mariager
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As i said, i use abour 1.3gig/3gig ram when it dies - So i don't think thats the problem.

Anyways, thanks a lot guys, i'll try tweaking the numbers and getting it to run correctly...
 
Matt Harrah
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want to look at how you are doing String stuff. If you do a lot of String manipulation (and I mean very large amounts in high volume) you can run into this when the string pool gets too big.

From Sun's site:
Interned java.lang.String objects are also stored in the permanent generation. The java.lang.String class maintains a pool of strings. When the intern method is invoked, the method checks the pool to see if an equal string is already in the pool. If there is, then the intern method returns it; otherwise it adds the string to the pool. In more precise terms, the java.lang.String.intern method is used to obtain the canonical representation of the string; the result is a reference to the same class instance that would be returned if that string appeared as a literal. If an application interns a huge number of strings, the permanent generation might need to be increased from its default setting.


One thing you look at is using StringBuffers or StringBuilders to concatenate series of strings, rather using + or +=, particularly inside loops.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String manipulation shouldn't have anything to do with the perm generation unless you use the intern() method. Which is definitely a possibility here, given the symptoms. But if intern() is not used, other string manipulation shouldn't affect this particular problem.

Jeppe: the overall memory usage isn't relevant here. The problem is that the MaxPermSize is too small for what you're using. Definitely try increasing that. But it's also possible that you've got some sort of memory leak that will expand to eventually overflow whatever size you have. If that's the case, increasing the MaxPermSize may delay the problem, but not prevent it. Still, it's very much worthwhile to try increasing the size as Akshay showed, to see what effect that has.
 
rajesh bala
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you try with the following options. This could force the JVM to cleanup the permgen as well.

-XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=128m

~Rajesh.B
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic