初始堆大小无效。无法创建Java虚拟机
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16416832/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Invalid initial heap size. Could not create the Java virtual machine
提问by John Smith
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:
我遇到了下一个问题:我正在尝试通过 startup.bat 手动启动 Tomcat,但似乎没有显示任何结果,然后我尝试运行 shutdown.bat 并且控制台显示下一个:
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
catalina.bat 是原始文件,我也检查了所有路径和选项(即 JAVA_HOME、JRE_HOME、CATALINA_BASE、CATALINA_HOME、CATALINA_TMPDIR)。tomcat 版本是 7.0.35 java v 1.6
采纳答案by John Smith
回答by sapy
This is your problem
Invalid initial heap size: -Xms256m -Xmx512m -XX:MaxPermSize=256m
这是你的问题
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 .
一些系统(可能是 windows JRE)理解Xms
并Xmx
以小写字母给出值。这里 256m 和 512m 分别表示 256MB 和 512MB。
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 .
某些机器(Ubuntu 上的 JDK 1.7)不理解small m for MB
. 因此,当我更改 Xms256m -Xmx512m 、to =>
Xms256 M-Xmx512 M 时,它开始工作。
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 listof error you can get for wrongly setting Xmxand Xmsvalues -
PS -> 在 Ubuntu 15 ( JDK 1.7 ) 上安装 IntelliJ 时遇到此错误,我编辑
/bin/idea.vmoptions
了 intelliJ 文件并开始工作。
java -Xmx4056M -Xms4056M HelloWorld
java -Xmx4056M -Xms4056M HelloWorld
Issue: Error occurred during initialization of VM , The size of the object heap + VM data exceeds the maximum representable size
问题:初始化VM时出错,对象堆+VM数据的大小超过了最大可表示大小
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.
原因: -Xms 或 -Xmx 的值大于或接近物理内存的大小,因为我的机器有 4GB 内存。
java -Xmx1056M -Xms2056M HelloWorld
java -Xmx1056M -Xms2056M HelloWorld
Issue: Error occurred during initialization of VM , Incompatible minimum, and maximum heap sizes specified
问题:VM 初始化期间出错,指定的最小和最大堆大小不兼容
Cause: value of -Xms is higher than -Xmx
原因:-Xms 的值高于 -Xmx
java -Xms2056M HelloWorld
java -Xms2056M HelloWorld
Issue: Error occurred during initialization of VM , Could not reserve enough space for object heap
问题:VM 初始化期间出错,无法为对象堆保留足够的空间
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
原因:只提供了 -Xms 而没有提供 -Xmx。如果您有拼写错误并且您指定了 -Xmx 而不是 -Xmx 两次,您也会收到此错误
java -Xms1024 M -Xmx1024M HelloWorld
java -Xms1024 M -Xmx1024M HelloWorld
Issue: Error occurred during initialization of VM , Too small initial heap
问题:初始化 VM 时出错,初始堆太小
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
原因:如果您在 1024 和 M 之间有空间,那么 JVM 会假设 -Xms 的大小仅为 1024 字节,并打印错误,提示 JVM 无法启动
回答by BartBiczBo?y
And in my case reason was to have -Xms
option before -javaagent
. Executing it in right order java -javaagent:xxx -Xms256m
did the trick.
就我而言,原因是-Xms
在-javaagent
. 以正确的顺序执行它就java -javaagent:xxx -Xms256m
成功了。
回答by Job Kavoya
I got the same error when initializing h2o for deep learning in R. Removed space between the set minimum memory size:
在 R 中为深度学习初始化 h2o 时,我遇到了同样的错误。删除了设置的最小内存大小之间的空间:
h2o.init(min_mem_size = "10 G") I got error:
h2o.init(min_mem_size = "10 G") 我收到错误:
Error occurred during initialization of VM Too small initial heap
虚拟机初始化时出错 初始堆太小
After removing space between 10 and G it worked:
删除 10 和 G 之间的空间后,它起作用了:
h2o.init(min_mem_size = "10G")
h2o.init(min_mem_size = "10G")
回答by The Quantum Physicist
This problem happened to me while trying to run Cassandra.
我在尝试运行 Cassandra 时遇到了这个问题。
Uninstalling Java 32-bit and installing Java 64-bit solved this problem for me.
卸载 Java 32 位并安装 Java 64 位为我解决了这个问题。
回答by avivamg
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:
从Oracle文档:
-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 clijava -Xs:64m -Xmx:1g -jar app.jar
在Java cli 上java -Xs:64m -Xmx:1g -jar app.jar
On docker-compose.ymlexample (different syntax):
关于docker-compose.yml示例(不同的语法):
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"