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.
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.
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.
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
Joined: Mar 06, 2006
Posts: 68
posted
0
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
Joined: Nov 29, 2005
Posts: 2300
posted
0
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.
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
Joined: Mar 06, 2006
Posts: 68
posted
0
Ben,
Thanks a million.. that worked.
Samanth.
Sam Venkata
Ranch Hand
Joined: Mar 06, 2006
Posts: 68
posted
0
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
Joined: Mar 06, 2006
Posts: 68
posted
0
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...
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?
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.
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.
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.
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.
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.