• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

java.lang.OutOfMemoryError: PermGen space

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
I have this memory exception( java.lang.OutOfMemoryError: PermGen space).
I know I need to increase the memory size by altering the JAVA_OPT's
-XX ermSize=128m -XX:MaxPermSize=196m parameters from the command line, but I use Tomcat 6.0 as a windows service, I want the changes to occur automatically instead of using the command prompt. Can somebody help me with this.
Thanks,
Samanth.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This forum is for J2ME, Mobile Device Apis.

I am going to move this to the Tomcat forum for the tomcat scripts is where you will want to add this stuff to.

Mark
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you chose the to include the "start menu items" when you installed Tomcat, go to:
Start -> Programs -> Apache Tomcat -> Configure Tomcat and click on the Java tab.
From there, you can add your JVM settings in the appropriate field.

 
Sam Venkata
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ben,
I changed the javaoptions parameter in service.bat and the parameter
-XX:MaxPermSize=128m is appended to the list of java options in the tomcat6w.exe.
Now I have another question.. it is how do I make sure that 128m is being used by the tomcat as the max perm size. Is there a way I could do it. please let me know.

Thanks,
Samanth.
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check method of class java.lang.Runtime.
 
Sam Venkata
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rahul,
I did see the Runtime class but it does not have any method that determines the perm space size. All I want to know is if the perm size is set to the new mwmory size...

Thanks,
Samanth.
 
Sam Venkata
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rahul,
I did see the Runtime class but it does not have any method that determines the perm space size. All I want to know is if the perm size is set to the new mwmory size...

Thanks,
Samanth.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry that I have diverted from the post.I do not think that you can find the prem size from the memory information that is available from Runtime Class.

This link might be useful.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Samanth Marisetty:
Ben,
I changed the javaoptions parameter in service.bat and the parameter
-XX:MaxPermSize=128m is appended to the list of java options in the tomcat6w.exe.
Now I have another question.. it is how do I make sure that 128m is being used by the tomcat as the max perm size. Is there a way I could do it. please let me know.

Thanks,
Samanth.




Here.
Paste this into a JSP in the ROOT webapp of Tomcat and hit it.
 
Sam Venkata
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ben,

Thanks a million.. that worked.

Samanth.
 
Sam Venkata
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ben,
Is there a way I could reclaim the committed memory which could be onr of the the problems we have on our server during high loads..

Thanks,
Samanth.
 
Sam Venkata
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what i meant was can I reclamin the used memory.. by the pattern that I noticed the used memory is never released until I restart the computer...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, it's normal for your memory consumption to continually rise with Java.
This doesn't necessarily mean that there is a problem. Java's garbage collector, intentionally runs only when it needs to because garbage collection (gc) is very expensive. So, a steady rise in heap space usage is normal.

If you have a memory leak (which in Java means unintentional object reference retention) then, when you get to the point where your app is about to run out of heap space gc will be run but won't be able to reclaim the memory held by those objects.

A common example for web applications is the failure to return database connections to the connection pool. If an app uses a connection pool but doesn't return the connections to the pool then, the pool manager will have to start creating a new connection for every request made to the app. Since the pool itself holds a reference to the connection, it can never be garbage collected. Since the pool never knows that a connection that was used is now available to go back into the pool, it just sits there and consumes memory.
Eventually, either the database will stop allowing more connections or the JVM will run out of heap space.

When this happens, allocating more heap space to the JVM will only postpone the problem.


After raising the amount of memory, are you still getting out of memory exceptions? If so, is it heap memory or perm gen space?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Samanth Marisetty:
Is there a way I could reclaim the committed memory which could be onr of the the problems we have on our server during high loads..



You can suggest that the JVM run garbage collection with the:
System.gc() command.
It may or may not happen and Sun recommends that you never put this command into your applications. It is much better to let the JVM manage gc than to try to micro-manage it yourself.

Of course, if you have a memory leak (as described above), running gc will get you nowhere because gc can't reclaim memory if it's being used by an active Java object.
 
Sam Venkata
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ben,
This is what is happening..

localhost
MEMORY TYPE: Code Cache
Used: 4 mb
Committed: 4 mb
Max: 48 mb
------------------------------------
MEMORY TYPE: PS Eden Space
Used: 25 mb
Committed: 33 mb
Max: 54 mb
------------------------------------
MEMORY TYPE: PS Survivor Space
Used: 0 mb
Committed: 1 mb
Max: 1 mb
------------------------------------
MEMORY TYPE: PS Old Gen
Used: 10 mb
Committed: 227 mb
Max: 455 mb
------------------------------------
MEMORY TYPE: PS Perm Gen
Used: 14 mb
Committed: 16 mb
Max: 128 mb
------------------------------------



localhost
MEMORY TYPE: Code Cache
Used: 4 mb
Committed: 4 mb
Max: 48 mb
------------------------------------
MEMORY TYPE: PS Eden Space
Used: 26 mb
Committed: 33 mb
Max: 54 mb
------------------------------------
MEMORY TYPE: PS Survivor Space
Used: 0 mb
Committed: 1 mb
Max: 1 mb
------------------------------------
MEMORY TYPE: PS Old Gen
Used: 10 mb
Committed: 227 mb
Max: 455 mb
------------------------------------
MEMORY TYPE: PS Perm Gen
Used: 14 mb
Committed: 16 mb
Max: 128 mb
------------------------------------



localhost
MEMORY TYPE: Code Cache
Used: 4 mb
Committed: 4 mb
Max: 48 mb
------------------------------------
MEMORY TYPE: PS Eden Space
Used: 27 mb
Committed: 33 mb
Max: 54 mb
------------------------------------
MEMORY TYPE: PS Survivor Space
Used: 0 mb
Committed: 1 mb
Max: 1 mb
------------------------------------
MEMORY TYPE: PS Old Gen
Used: 10 mb
Committed: 227 mb
Max: 455 mb
------------------------------------
MEMORY TYPE: PS Perm Gen
Used: 14 mb
Committed: 16 mb
Max: 128 mb
------------------------------------


the Eden Space is increasing each time a request comes.... all I was trying to know is that if it could be made 0 if there are no requests for some time.

Thanks,
Samanth.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eden space is heap memory.
I will never go to zero while the app is running.
Tomcat and your app will, naturally, always hold on to some of it.

Again, unless you have a memory leak in your app, a steady rise in consumption is normal and nothing to be alarmed about.


Make a JSP called gc.jsp with this in it:


Put it on your system,
Hit your app till the heap space rises a bit.
Hit gc.jsp
Then look at the JSP the other JSP you just made.
You should see a drop in heap space usage.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again, JVMs treat System.gc as a suggestion and may, according to the conditions within the JVM ignore it so don't be alarmed if what I suggested in the last post doens't cause a drop in memory consumption.

This might interest you:
http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html
[ March 30, 2007: Message edited by: Ben Souther ]
 
Sam Venkata
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ben,
Thanks a lot for the information, now I understand that eden space is designed to grow but what I could not understand is whether permgen behaves the same way as edenspace. I was looking at the jconsole memory monitoring and managing tool and found that isUsageThresholdSupported for the edenspace is true, but what I understand from
http://java.sun.com/javase/6/docs/technotes/guides/management/mxbeans.html
is that it should be false. Can you please let me know if what I understand is correct.
And also I would like to know if the permgen space could keep growing because it is the area where the classes, methods and such are stored and if so is there a way I could free it .
I really appreciate your help.

Thanks,
Samanth.
 
He's my best friend. Not yours. Mine. You can have this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic