Solved

PermGen - OutOfMemoryError

Posted on 2009-07-13
14
331 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +3
14 Comments
 
LVL 60

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:Ken Clement
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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 60

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 60

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:
Ken Clement 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

623 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