Results 1 to 9 of 9
Thread: Problem with PermGen Space
- 11-24-2010, 08:48 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 13
- Rep Power
- 0
Problem with PermGen Space
Hello everybody
I have a problem with JBoss, that is: I did deploy a project and after a
few hours of execution (without new deploy) I have "Java.lang.OutOfMemoryError: PermGen space".
Why garbgage collector does not succeed in deallocate memory? What may be the problem?
The question associated tieh Eclipse: do you think that it could be a good idea to set to null all the variables of all the methods of all
the classes of the project in a finally block? (in this case, in Eclipse, is there a tool that allow me to do this
automatically?).
Thank you everybody for your attention!
- 11-24-2010, 09:01 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
PermGen is the space used to store the classes.
It isn't part of the regular heap so doesn't go through the garbage collection cycle (as such).
Use -XX:MaxPermSize to set it (I think that's the switch).
- 11-24-2010, 09:20 AM #3
Member
- Join Date
- Oct 2009
- Posts
- 13
- Rep Power
- 0
Thank you for your answer! I will do it instantly.
So, from your answer I understand that it is not useful to set, in a finally block, all the variables at null. Isn't it?
- 11-24-2010, 09:34 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
It is never (except in one or two really really specific cases) necessary to set a variable to null in order to try and get something garbage collected. Once it's out of scope it is eligible.
Though that has nothing to do with PermGen.
- 11-24-2010, 11:08 AM #5
Member
- Join Date
- Oct 2009
- Posts
- 13
- Rep Power
- 0
Ok, thank you again for your answer.
I am using visualVM and jmap+jhat: I did realize what you wrote, because the heap space is correctly cleaned by the GC while the permgen space only grows and never decrease.
I did set -XX:MaxPermSize to 512, and the problem seems to be fixed.
But I am afraid that, as permgen space does not seem to decrease, the problem could raise again, that is that it's just postponed.
What do you think about it? Have you something to suggest me?
- 11-24-2010, 11:16 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
PermGen will increase simply because, as a program runs, more classes tend to get loaded up. Eventually you will have loaded all the classes required by your program and it will then be steady.
- 11-24-2010, 02:22 PM #7
Member
- Join Date
- Oct 2009
- Posts
- 13
- Rep Power
- 0
Ok, thank you!
I am now using JVisualVM for trying to understand if are there programming errors in my code that do not prevent my application to work fine but that causes too memory usage. But: as I perform a HeadDump I can find, for example, 203489 instances of java.lang.String. Is there a way to know in which classes/object are they instantiated (for String instances, but also for other classes as ArrayList, ...) ?
- 11-24-2010, 02:33 PM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
I don't know if the one you're using shows a graph of the largest objects, but Eclipse MAT does. That's the best way of spotting protential problem areas. SImply looking at raw numbers (like number of String objects) doesn't tend to point you in the right direction.
Also, there's no point doing all this if you haven't encountered a problem yet. To find out if there is a problem the best technique is to load test your program somehow and see if it falls over. There are also memory monitors you can use that will attach to the JVM and allow you to watch a graph as the memory is used and then garbage collected. It's like watching a (very slow) heart beat.
:)
- 11-24-2010, 03:29 PM #9
Member
- Join Date
- Oct 2009
- Posts
- 13
- Rep Power
- 0
Similar Threads
-
Image Problem overflowing Heap Space
By The Bear Jew in forum Java 2DReplies: 4Last Post: 10-16-2010, 06:58 PM -
Problem in Adding Gutter Space between columns in JTextPane
By png in forum AWT / SwingReplies: 1Last Post: 06-07-2010, 07:10 AM -
Heap Space Problem
By segolas in forum Advanced JavaReplies: 6Last Post: 01-14-2010, 11:29 AM -
Problem with Java Heap Space using Socket
By mvillara in forum NetworkingReplies: 3Last Post: 08-21-2009, 04:45 AM -
regex problem - allowing optional space
By Norm in forum Advanced JavaReplies: 26Last Post: 10-06-2008, 04:38 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks