i am getting error in stopping tomcat service in server using putty
error is
`[root#vps ~]# service tomcat7 stop
Shutting down Tomcat7:
Using CATALINA_BASE: /usr/tomcat7
Using CATALINA_HOME: /usr/tomcat7
Using CATALINA_TMPDIR: /usr/tomcat7/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/tomcat7/bin/bootstrap.jar
/usr/tomcat7/bin/tomcat-juli.jar
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
`
please help ...
Try increasing the heap memory usage for java.
You can do so by editing catalina.bat (for Windows) and catalina.sh (for Linux).
Try editing JAVA_OPTS.
For Linux
export JAVA_OPTS="-server -Xmx512m"
For Windows
set JAVA_OPTS=-server -Xmx512m
You need to look at your memory settings for tomcat, to help set heap size look at
Increase Tomcat memory settings
Take a look at the question about memory size
Could not reserve enough space for object heap
Related
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.
in my company we develope an enterprise web application in Spring (Flex frontend) and deploy this app to our customers in Tomcat 6 in SAAS style.
Recently we are suffering from (seemingly) random OutOfMemory errors so after investigation I knew that we should inspect the memory dump of the JVM in the moment of the error.
The JVM we use is 1.6.18 and the Tomcat version is Tomcat 7.0.23 under Windows Server 2008.
I added the parameter -XX:+HeapDumpOnOutOfMemoryError in the Tomcat monitor panel (under Java tab) but the machines aren't producing any dump.
The full java options are set as follows on the server we are investigating:
-Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 7.0
-Dcatalina.base=C:\Program Files\Apache Software Foundation\Tomcat 7.0
-Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 7.0\endorsed
-Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 7.0\temp
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=C:\Program Files\Apache Software Foundation\Tomcat 7.0\conf\logging.properties
-XX:PermSize=128m
-XX:MaxPermSize=1024m
-Xms1024m
-Xmx6144m
-XX:+HeapDumpOnOutOfMemoryError
-Dcom.sun.management.jmxremote.port=3333
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
As you can see the max heap size is pretty large (6 Gigs) since out app is particurarly heavy.
I added for testing reasons the jmx parameters in order to view the JVM status in real time with VisualVM, but nothig occurred while I was looking at it.
All that the stderr shows is this:
java.lang.OutOfMemoryError
Nothing before it (except other errors that I don't know if correlated, but they are logged hours or several minutes before the OOM) and nothing after it.
It seems strange to me that it doesn't report the memory section (Java heap size, or Permgen Space).
Maybe the memory heap reserved is too big and the JVM can't write it at since it's in a critical state (OOM)?
Maybe the JMX parameters are messing things up?
This is the VisualVM screenshot of currently running JVM:
UPDATE:
I installed on another tomcat installation (same version as the one in which the problem originated and same java options) the same web application modified to manually provoke an OOM by undefinitely filling an arraylist in an infinite loop.
The test proved that the java option -XX:+HeapDumpOnOutOfMemoryError works, since a memory dump was produced after I provoked the OOM; in this case however the error was:
java.lang.OutOfMemoryError: Java Heap space
following with the stack trace.
So it seems that the problem is not with my JVM args notation but with the particular kind of error I'm encountering.
Another peculiarity is that after throwing the OOM error in my test, the app continued to work in Tomcat. The OOM in my original issue on the other hand causes the stop of the Tomcat service.
Sadly without a stack trace taken a moment before it stops it looks difficult to further investigate. :(
Add -XX:HeapDumpPath="/some/path/dump.out" to your JVM args explicitly set the heap dump file location
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.
I'm having some problems with Tomcat. I'm deploying a Grails application and as I were adding new features I got this (sadly well known) error in the stacktrace file:
Caused by: java.lang.OutOfMemoryError: PermGen space
2014-01-13 19:28:35,753 [http-bio-8080-exec-26] ERROR StackTrace - Full Stack Trace:
org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.OutOfMemoryError: PermGen space
at gsp_liquidaciones_liquidacionDeComplejolist_gsp$_run_closure2.doCall(gsp_liquidaciones_liquidacionDeComplejolist_gsp.groovy:84)
at gsp_liquidaciones_liquidacionDeComplejolist_gsp.run(gsp_liquidaciones_liquidacionDeComplejolist_gsp.groovy:105)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
...
I have an Windows installer-based tomcat installation and I don't have an catalina.bat file also. Googling many pages suggest to modify this file (catalina.bat) or register JAVA_OPTS variable, but nothing works. So, where do I have to specify this parameters?:
SET JAVA_OPTS="-Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC”
I have tried to modify the Java Options through Apache Tomcat 7 Properties window but after the modifications the server can't start.
My computer has 4Gb RAM installed.
Thanks in advance.
For the following system specifications:
Windows 7 64-bit
4 GB installed RAM
Intel Core i7 processor
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
The Tomcat 7 Java properties for an acceptable behavior MIGHT be:
You should have a small windows application 'tomcat6w.exe' or 'tomcat7w.exe' when tomcat was installed as a windows service. When you start this application it has a tab 'Java' where you can set the JVM parameters. For more details see more memory to Tomcat service.
You need to enter only the parameters which start with -X.
This work for me in apache-tomcat-8.0.15, but i think it would be the same for all to tomcat's version.
I had executed regedit and found this path:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tomcat8
And change ImagePath key to:
C:\apache-tomcat-8.0.15\bin\tomcat8.exe //RS//Tomcat8 ++JvmOptions -XX:PermSize=128m -XX:MaxPermSize=512m
I've faced the next problem:
I'm trying to start Tomcat manually via startup.bat, but it seems not to show any results, then I've tried to run shutdown.bat and the console shows next:
D:\apache-tomcat-7.0.35\bin>startup.bat
Using CATALINA_BASE: "D:\apache-tomcat-7.0.35"
Using CATALINA_HOME: "D:\apache-tomcat-7.0.35"
Using CATALINA_TMPDIR: "D:\apache-tomcat-7.0.35\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk1.6.0_31"
Using CLASSPATH: "D:\apache-tomcat-7.0.35\bin\bootstrap.jar;D:\apache-tomcat-7.0.35\bin\tomcat-juli.jar"
D:\apache-tomcat-7.0.35\bin>shutdown.bat
Using CATALINA_BASE: "D:\apache-tomcat-7.0.35"
Using CATALINA_HOME: "D:\apache-tomcat-7.0.35"
Using CATALINA_TMPDIR: "D:\apache-tomcat-7.0.35\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk1.6.0_31"
Using CLASSPATH: "D:\apache-tomcat-7.0.35\bin\bootstrap.jar;D:\apache-tomcat-7.0.35\bin\tomcat-juli.jar"
Invalid initial heap size: -Xms256m -Xmx512m -XX:MaxPermSize=256m
Could not create the Java virtual machine.
catalina.bat is original, also I've checked all pathes and opts(i.e. JAVA_HOME, JRE_HOME, CATALINA_BASE, CATALINA_HOME, CATALINA_TMPDIR).
tomcat version is 7.0.35
java v 1.6
This is your problem
Invalid initial heap size: -Xms256m -Xmx512m -XX:MaxPermSize=256m
Some systems ( May be windows JRE) understands Xms and Xmx values given in small letters. here 256m and 512m denotes 256MB and 512MB respectively .
Some machine(JDK 1.7 on Ubuntu ) doesn't understand small m for MB . So when I changed Xms256m -Xmx512m , to => Xms256M -Xmx512M , it started working .
P.S -> I got this error while installing IntelliJ on Ubuntu 15 ( JDK
1.7) , I edited /bin/idea.vmoptions file of intelliJ and It started working.
Here is a list of error you can get for wrongly setting Xmx and
Xms values -
java -Xmx4056M -Xms4056M HelloWorld
Issue: Error occurred during initialization of VM , The size of the object heap + VM data exceeds the maximum representable size
Cause: the value of either -Xms or -Xmx is higher than or close to the size of physical memory, as my machine has 4GB memory.
java -Xmx1056M -Xms2056M HelloWorld
Issue: Error occurred during initialization of VM , Incompatible minimum, and maximum heap sizes specified
Cause: value of -Xms is higher than -Xmx
java -Xms2056M HelloWorld
Issue: Error occurred during initialization of VM , Could not reserve enough space for object heap
Cause: Only -Xms was provided and -Xmx was not provided. you will also get this error if you have a typo and instead of -Xmx you have specified -Xms two times
java -Xms1024 M -Xmx1024M HelloWorld
Issue: Error occurred during initialization of VM , Too small initial heap
Cause: If you had space between 1024 and M than JVM assumes the size of -Xms as 1024 bytes only and print error that it's too small for JVM to start
This problem happened to me while trying to run Cassandra.
Uninstalling Java 32-bit and installing Java 64-bit solved this problem for me.
The problem : You try to initial the minimum and maximum heap size of your application though appears that you're having some syntax issue. You need to set it properly. Pay attention that you minimum and maximum size points are supported related to your machine memory that your application is running.
From Oracle Documentation:
-Xms
The -Xms option sets the initial and minimum Java heap size.
The Java heap (the “heap”) is the part of the memory where blocks of memory
are allocated to objects and freed during garbage collection.
Note: -Xms does not limit the total amount of memory that the JVM can use.
Format: -Xms<size>[g|G|m|M|k|K]
-Xmx
This option sets the maximum Java heap size.
The Java heap (the “heap”) is the part of the memory where blocks of memory
are allocated to objects and freed during garbage collection.
Depending upon the kind of operating system you are running,
the maximum value you can set for the Java heap can vary.
Note: -Xmx does not limit the total amount of memory that the JVM can use.
Operation
Format: -Xmx<size>[g|G|m|M|k|K]
Examples:
On java cli java -Xms:64m -Xmx:1g -jar app.jar
On docker-compose.yml example (different syntax):
version: '3'
services:
jenkins:
image: jenkins/jenkins:lts
container_name: jenkins
user: jenkins
environment:
- JAVA_OPTS=-Xms512m -Xmx2048m
ports:
- "0.0.0.0:8080:8080"
got the correct parameters(JAVA_OPTS) from here. I've set them in setenv.bat.
I got the same error when initializing h2o for deep learning in R. Removed space between the set minimum memory size:
h2o.init(min_mem_size = "10 G") I got error:
Error occurred during initialization of VM
Too small initial heap
After removing space between 10 and G it worked:
h2o.init(min_mem_size = "10G")
And in my case reason was to have -Xms option before -javaagent. Executing it in right order java -javaagent:xxx -Xms256m did the trick.
You may get this issue even after physical memory available in the system.
On most 32-bit java version the maximum heap size will range from 1.4G to 1.6G. For more details Please got through on this link
If you have to initialise JVM more than 1.4G to 1.6G of heap memory then you should install 64 bit java version.