PermGen space error while application is running - java

My Web application is running on tomcat apache-tomcat-6.0.35 and It was working fine witout any issue.But today I show bellow exception in catalina.out log and was unable to login to the system.
Jul 9, 2013 2:40:15 PM org.apache.coyote.http11.Http11Processor process
SEVERE: Error processing request
java.lang.OutOfMemoryError: PermGen space
I was under impression this exception can be ocuured when you deploy or redeploy a application. But I got this when the application is running without any issues. What could be the reason for this. Kindly advice

Each webapp in Tomcat has a separate class loader with a separate set of loaded classes. When we start Tomcat it does not load all classes of all its apps at once but rather it loads the apps lazily. When an app becomes active it starts loading its classes and it may happen that JVM runs out permgen space. That is, it may happen even without redeploying apps.

add these Optionsto JVM command line when Tomcat is started Or add to IDE VM Options
-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
OR
-XX:MaxPermGen=128M

It sounds like one of your webapps is consuming a lot of memory. Have you tried raising the PermGen size? In $CATALINA_HOME/bin/catalina.sh you can add
-XX:PermSize=512m -XX:MaxPermSize=512m
to your JAVA_OPTS so that it allocates enough space to run.

You are getting out of permGen space, try to change this parameters on your tomcat start script
/etc/init.d/tomcat6
JAVA_OPTS="-Djava.awt.headless=true -XX:MaxPermSize=512M"
Set the memory amount as you need.

It definitely is an error that often shows up during deployments. I've seen it occur any number of times in both Grails and Java applications. You can increase your permgen space by adjusting the JVM startup param -XX:MaxPermSize, ie:
-XX:MaxPermSize=256m
This thread covers the issue in detail: Thread

I had this error a few days ago. I fixed it by restarting the real machine - there was a problem with a deploy.
Also you can fix it by adding
JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8
-server -Xms1536m -Xmx1536m
-XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m
-XX:MaxPermSize=256m -XX:+DisableExplicitGC"
See possible fix

Related

Constant dspace error java.lang.OutOfMemoryError: Java heap space

I have a DSpace server, after uprading from version 4.3 to 5.1, it constantly stops working after some hours with following error:
java.lang.OutOfMemoryError: Java heap space
I've read answers to the same questions, but they didn't help me.
My JAVA_OPTS: -Xmx4096M -Xms4096M -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8
Here are my logs:
dspace.log.2015-04-21: http://jpst.it/ylU4
tomcat7-stderr.2015-04-20.log: http://jpst.it/ylTN
localhost_access_log.2015-04-20.txt: http://jpst.it/ylTT
I searched the internet for a solution and could not find one, does any one have a clue?
Your tomcat log file quite clearly says that it isn't using the JAVA_OPTS you're passing in:
INFO: Command line argument: -Xmx256m
In my experience, DSpace 5 needs at least 512MB; your 4GB look a little excessive unless your DSpace instance is very big / gets lots of traffic.
You aren't telling us what operating system you're using, so it's hard to give advice on how where to set these properly. Start with your tomcat startup script and/or the tomcat configuration files. On my Red Hat Enterprise Linux 6.6 boxes (with tomcat6), the correct place for the memory settings is /etc/tomcat6/tomcat6.conf.

tomcat not generating hprof file on outofmemory error

I have some memory leak issue in my web app which is deployed in tomcat. To find the root cause I enabled the HeapDumpOnOutOfMemory error by setting:
-XX:-HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/usr/local/tomcat/logs
and the memory settings in the tomcat is:
-Xms256m -Xmx768m -XX:PermSize=128m -XX:MaxPermSize=256m
When the out of memory issue happened, I see
java.lang.OutOfMemoryError: Java heap space
on the tomcat log file, but the .hprof file is not generated. Am I missing some settings here?
As #beny23 wrote you should use -XX:+HeapDumpOnOutOfMemoryError
and as is stated here:
The -XX:HeapDumpOnOutOfMemoryError Option This option tells the Java
HotSpot VM to generate a heap dump when an allocation from the Java
heap or the permanent generation cannot be satisfied. There is no
overhead in running with this option, so it can be useful for
production systems where the OutOfMemoryError exception takes a long
time to surface.
Check also your Java version since this option was introduced in 1.4.2 update 12, 5.0 update 7.

PermGen Space Issue

Environment: Windows Server 2003 x86 Intel Xeon 2.3 4gb Ram | tomcat 7.0.27 | jdk 1.7.0.25
I am facing the OutOfMemoryError. SO suggests using java options to increase the permgen space using following options
-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1536m -Xmx1536m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC
However tomcat status page still shows the permgen memory as 64MB. Why cant it pick up the value specified in the parameters?
There is no PermGen in the status page, see this http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html#Introduction.
Anyways you conf seems OK
Since PermGen is a java thing (not tomcat) you should use java tools to check it, take a look at this.
As your settings seem ok, check the way you apply them: If you start tomcat via batch file, create setenv.bat with the content
CATALINA_OPTS="-Dyour-settings-from-above ... all of them"
If you start a service, you'll need to update the service configuration - as I'm not on Windows, it's a long time since I did that. Did you use the tomcatw.exe to create/configure the service? Not sure...

Could not create the Java virtual machine

facing some problem with java virtual machine initialization. when i am using root account i can properly work with java. but when i am a user account it returns following errors
user#host# $JAVA_HOME/bin/java -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
It does not seems like a memory issue as the same command works with root account. Available memory (free -m) is more than 1200MB
Also i have tried increasing the JVM memory limits
Just be careful. You will get this message if you try to enter a command that doesn't exist, e.g.:
/usr/bin/java -v
I had this issue today, and for me the problem was that I had allocated too much memory:
-Xmx1024M -XX:MaxPermSize=1024m
Once I reduced the PermGen space, everything worked fine:
-Xmx1024M -XX:MaxPermSize=512m
I know that doesn't look like much of a difference, but my machine only has 4GB of RAM, and apparently that was the straw that broke the camel's back. The Java VM was failing immediately upon every action because it was failing to allocate the memory.
Set the JVM memory:
export _JAVA_OPTIONS=-Xmx512M
The problem got resolved when I edited the file /etc/bashrc with same contents as in /etc/profiles and in /etc/profiles.d/limits.sh and did a re-login.
Make sure the physical available memory is more then VM defined min/max memory.

Redeploying a Grails App using Jenkins on Tomcat fills PermGen Space

Currently we are having various problems with the deployment of our Grails application on Tomcat 6, mainly it's about memory usage issues and redeployment via Jenkins.
The Application eats more and more memory, and we tried to resolve this with CMSPermGenSweepingEnabled (we are using UseConcMarkSweepGC), so now the temporary classes used by Groovy should get cleaned up.
What still is a problem is that on each Redeploy (with jenkins) the app needs around 150 mb of additional Permgen space ... any idea how to avoid this?
We are using Grail 1.3.7, and our current configuration flags are
-Djava.util.logging.config.file=/var/lib/tomcat6/conf/logging.properties
-Djava.awt.headless=true
-Xms2048M
-Xmx2048M
-XX:MaxPermSize=1024m
-XX:PermSize=1024m
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled
-XX:+UseConcMarkSweepGC
-Djava.net.preferIPv4Stack=true
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.endorsed.dirs=/usr/share/tomcat6/endorsed
-Dcatalina.base=/var/lib/tomcat6
-Dcatalina.home=/usr/share/tomcat6
-Djava.io.tmpdir=/tmp/tomcat6-tmp
It's very popular tomcat issue, they even have some recommendations: http://wiki.apache.org/tomcat/OutOfMemory, but at most cases it's works only for small or fully controlled project (mean 'project without any external library'). All solid projects I ever seen fails under tomcat with this error :(
My recomendation - restart Tomcat instance after deploy.
We've experienced similar issues with our Grails applications on Tomcat. Our solution is the same as what Igor suggests, restart Tomcat after a deploy.
We have two production servers setup in a cluster so they share sessions. We take one server down, undeploy the application, restart tomcat, deploy the new version of the application, and bring that server back up. Then repeat the process on the other server. So far this is working for us.

Categories

Resources