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.
Related
In my server, I have total 16GB memory. JVM max memory(Xmx)is assigned to 12GB. In JVM, we are running WSO2 ESB. We had set MaxMetaspaceSize=1g in JVM. That frequently gave us the following error.
java.lang.OutOfMemoryError: Metaspace
Then we removed the MaxMetaspaceSize=1g parameter from JVM. Then we came up the following two errors in JVM and we experienced slowness in the application as well.
Caused by: java.lang.OutOfMemoryError: Java heap space
Caused by: java.lang.OutOfMemoryError: Required array size too large
What can be a possible solution to get rid of initial Metaspace error?
Follow below steps:
Open catalina.sh from tomcat/bin.
Change JAVA_OPTS to
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"
Restart your tomcat
There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 1048576 bytes for AllocateHeap
# An error report file with more information is saved as:
# C:\jboss-eap-services-6.4.4\bin\hs_err_pid6632.log
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m;
support was removed in 8.0
With the problem above, I'm trying to start the jboss server. I tried some steps and I could not find the right solution.
Please use the following setting to allocate the memory for the permanent location -Xms1024m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m -XX:-UseGCOverheadLimit
You can try to increase eclipse memory, you can do this in le eclipse.ini file (near eclipse executable file) or in the command line arguments :
-Xms256m
-Xmx16348m
It is JBoss (not Eclipse) that is crashing. So increasing Eclipse's memory is futile! (It might make things worse, in fact.)
The second thing to note is that you are running out of space in a native allocation request, so increasing the regular heap's size will not help. Options like the following will probably NOT help! (They might make things worse, in fact.)
-Xms1024m -Xmx1024m -XX:-UseGCOverheadLimit # USELESS
The third thing to note is that your JVM doesn't have a PermGen space, so fiddling with the PermGen size via
-XX:PermSize=512m -XX:MaxPermSize=512m # USELESS
is futile. (That is what Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0 is saying.)
So what is the real problem?
Well you are running a 64-bit JRE, so it is not an architectural problem. (On a 32-bit JRE, the JVM's address space has hard limits ...)
In fact, it is a problem outside of the JVM itself. Basically, the JVM has asked the OS for more memory, and the OS has said "Nope!". I can thing of two possible explanations:
There may be a per-process "ulimit" in place, that is restricting the process size. Your JVM has requested beyond that limit.
The OS may have run out of virtual address space or mappable virtual memory. The former is unlikely. The latter typically arises because your OS doesn't have enough RAM and/or swap space. This can also happen is you are running within a virtual machine that is ... less than generous endowed with memory resources.
Now it appears that this may be happening when the JVM is trying to grow the Java heap. But either way, the problem is not the size of the Java heap.
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.
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
According to documentation one could automatically take a heap dump when the application encounters an OutOfMemoryException.
After OutOfMemoryException process just disappear from left menu.
How does this feature works in VisualVM?
Thanks.
C:\work\temp>java -XX:HeapDumpPath=c:/work/temp/file.hprof -XX:+HeapDumpOnOutOfMemoryError -jar example.jar
As far as I know, that option in JVisualVM is equivalent to specifying -XX:+HeapDumpOnOutOfMemoryError as a JVM parameter. This causes the JVM to create a heap dump file when it encounters an OutOfMemoryError. This file can be then loaded into JVisualVM (or into a profiler) and analyzed there. The directory where the file is stored is defined by the -XX:HeapDumpPath parameter.
See also:
Troubleshooting Guide for Java SE 6 with HotSpot VM
Java HotSpot VM Options
StackOverflow: Using HeapDumpOnOutOfMemoryError parameter
Seems application just exited upon OOM. In this case, you must run your app with special -XX params. See "dump" params in JVM documentation. After application dies, you can examine dump in your tool.