Solved

PermGen - OutOfMemoryError

Posted on 2009-07-13
14
327 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
ID: 24840707
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
ID: 24840763
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
ID: 24840874
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 
LVL 59

Expert Comment

by:Kevin Cross
ID: 24841007
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
ID: 24841235
Ahh it's *that* kind of PermGen.. ;-)
0
 

Author Comment

by:mdoland
ID: 24842722
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
ID: 24842794
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
 
LVL 2

Accepted Solution

by:
KenClement earned 200 total points
ID: 24843554
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
ID: 24844817
do a diff on the two releases to get an idea as to what has triggered it.
0
 

Author Comment

by:mdoland
ID: 24846997
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
ID: 24847006
not really, assuming the memory is available on the box
0
 

Author Comment

by:mdoland
ID: 24847017
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
ID: 24847042
correct, its a seperate allocation
0
 
LVL 6

Assisted Solution

by:jwenting
jwenting earned 100 total points
ID: 24849021
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 Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hibernate example issues from command prompt 10 50
runtime exception 2 41
Chrome and Firefox Java 5 50
Running JavaFX on the Raspberry Pi 27 38
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

840 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