Solved

PermGen - OutOfMemoryError

Posted on 2009-07-13
14
323 Views
Last Modified: 2013-12-29
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
0
Comment
Question by:mdoland
  • 3
  • 3
  • 3
  • +3
14 Comments
 
LVL 59

Expert Comment

by:Kevin Cross
Comment Utility
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
 
LVL 2

Expert Comment

by:KenClement
Comment Utility
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
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
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
 
LVL 59

Expert Comment

by:Kevin Cross
Comment Utility
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
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Ahh it's *that* kind of PermGen.. ;-)
0
 

Author Comment

by:mdoland
Comment Utility
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
 
LVL 59

Expert Comment

by:Kevin Cross
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 2

Accepted Solution

by:
KenClement earned 200 total points
Comment Utility
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
 
LVL 92

Expert Comment

by:objects
Comment Utility
do a diff on the two releases to get an idea as to what has triggered it.
0
 

Author Comment

by:mdoland
Comment Utility
Are there any potential risks in setting up those values? I plan to put it up to 128m and 192m.
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
not really, assuming the memory is available on the box
0
 

Author Comment

by:mdoland
Comment Utility
And as I understand, it is not taken from the rest of the heap, right?
0
 
LVL 92

Assisted Solution

by:objects
objects earned 200 total points
Comment Utility
correct, its a seperate allocation
0
 
LVL 6

Assisted Solution

by:jwenting
jwenting earned 100 total points
Comment Utility
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

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now