Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid initial heap size. Could not create the Java virtual machine

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

like image 567
John Smith Avatar asked May 07 '13 10:05

John Smith


2 Answers

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

like image 101
sapy Avatar answered Nov 02 '22 23:11

sapy


This problem happened to me while trying to run Cassandra.

Uninstalling Java 32-bit and installing Java 64-bit solved this problem for me.

like image 39
The Quantum Physicist Avatar answered Nov 03 '22 00:11

The Quantum Physicist