PermGen - OutOfMemoryError

I have a client application that run into OutOfMemoryError after having been running for a pretty short time, a couple of hours. I have increased the size of it, but it doesn't seem to have any effect. The error still shows up. What can I do to solve this? Is it bad coding of some sort? I don't just want to create more space unless there is a good reason for it.

The JVM is 1.5
mdolandAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Ken ClementConnect With a Mentor Software DeveloperCommented:
Reference:
http://www.alessandroribeiro.com/?q=en/node/33
http://www.alessandroribeiro.com/?q=en/node/39
http://www.alessandroribeiro.com/?q=en/node/41

Relevant Quote: (??)
"The Java language features dynamic class loading, so classes will be loaded on demand and the permgen heap size will grow as well. But, if in the long term, your permgen area is still steadly growing, you are probably using some kind of bytecode generation framework which is misbehaving or you are using it incorrectly. Analyse that and rethink what you are doing."
0
 
Kevin CrossChief Technology OfficerCommented:
It could be a multitude of things, especially as you eluded too a code error (memory leak).  Large objects that are not being properly disposed of once they are no longer being used that new instances get created for over and over in course of application execution.  If you have an idea of the class / method specifically being executed when you get this error (maybe through the stack trace -- can post in code snippet here) you can paste that classes code here in a code snippet for evaluation.

Regards,
Kevin
0
 
Ken ClementSoftware DeveloperCommented:
The problem as you describe it is almost certainly a coding issue.  It is most likely that objects are being allocated that the garbage collector cannot touch because references to them still exist somewhere.  Another possibility is that objects are being allocated at such a rate between the normal garbage collection cycle that memory is exhausted before the garbage collector even has a chance (from your description though, I'd heavily lean to the first explanation).

Look to profile the client application (let us know if you are unsure how to do that) monitor the memory usage; if it is monotonically increasing that is a smoking gun for explanation #1.  You will then need to determine why the application allocates and tends not to return memory.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
CEHJCommented:
Your title 'PermGen' gives me a clue that you could be permuting a collection. Unless you're reusing the memory for each permutation, e.g. if you were somehow adding to the memory usage, the numbers can quickly reach stratospherice levels
0
 
Kevin CrossChief Technology OfficerCommented:
Here is some information on PermGen (permanent generation in JVM):
http://www.brokenbuild.com/blog/2006/08/04/java-jvm-gc-permgen-and-memory-options/

There are some links that should help in determining which classes are being put into PermGen and whether or not increasing the MaxPermSize will be a good idea for you or will just delay the amount of time between the issues as you just give more memory to be leaked before application dies.  However, it could be as your memory could just be getting exhausted as such a fast rate that garbage collection doesn't get to occur as KenClement pointed out as scenario #2 above.
0
 
CEHJCommented:
Ahh it's *that* kind of PermGen.. ;-)
0
 
mdolandAuthor Commented:
To clearify: This is what I am talking about:
http://www.freshblurbs.com/explaining-java-lang-outofmemoryerror-permgen-space

The product is a mature product that is used by very many people. We have never experience this problem, and suddenly after a new release, it occurs in the client.

We increased the size to 90 from the default 64, but it shows upp pretty fast anyway.
0
 
Kevin CrossChief Technology OfficerCommented:
Is there error message occurring on each individual client OR on the system hosting the application since you indicated "that is used by very many people".  

If by that statement, you meant the product is a mature boxed application that itself has a heavy user base, then check the community/forum for your application vendor and/or their support site to see if this new version has know memory leak issue that they may have a patch for.  You may find others have found an appropriate setting like PermSize=192m / MaxPermSize=192m or fix to the root issue if it is not based on the permanent heap size itself.

Best regards,
Kevin
0
 
objectsCommented:
do a diff on the two releases to get an idea as to what has triggered it.
0
 
mdolandAuthor Commented:
Are there any potential risks in setting up those values? I plan to put it up to 128m and 192m.
0
 
objectsCommented:
not really, assuming the memory is available on the box
0
 
mdolandAuthor Commented:
And as I understand, it is not taken from the rest of the heap, right?
0
 
objectsConnect With a Mentor Commented:
correct, its a seperate allocation
0
 
jwentingConnect With a Mentor Commented:
PermGen problems are almost universally caused by calling (implicitly or explicitly) String.intern() frequently.
Eclipse for example has this in some versions when working extensively with XML and HTML/JSP files.

Some XML parsers may do this as well, and especially classes that implement the Cloneable interface and use String.intern() to create deep copies of String fields (usually an unnecessary precaution).
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.