简体   繁体   English

初始堆大小无效。 无法创建Java虚拟机

[英]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:我遇到了下一个问题:我正在尝试通过 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(ie JAVA_HOME, JRE_HOME, CATALINA_BASE, CATALINA_HOME, CATALINA_TMPDIR). catalina.bat 是原始文件,我也检查了所有路径和选项(即 JAVA_HOME、JRE_HOME、CATALINA_BASE、CATALINA_HOME、CATALINA_TMPDIR)。 tomcat version is 7.0.35 java v 1.6 tomcat 版本是 7.0.35 java v 1.6

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.某些系统(可能是 windows JRE)理解以小写字母给出的XmsXmx值。 here 256m and 512m denotes 256MB and 512MB respectively .这里 256m 和 512m 分别表示 256MB 和 512MB。

Some machine(JDK 1.7 on Ubuntu ) doesn't understand small m for MB .某些机器(Ubuntu 上的 JDK 1.7)不理解small m for MB So when I changed Xms256m -Xmx512m , to => Xms256 M -Xmx512 M , it started working .因此,当我将 Xms256m -Xmx512m 更改to => Xms256 M -Xmx512 M 时,它开始工作。

PS -> 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. PS -> 我在 Ubuntu 15(JDK 1.7)上安装 IntelliJ 时遇到这个错误,我编辑了/bin/idea.vmoptions文件,它开始工作了。

Here is a list of error you can get for wrongly setting Xmx and Xms values - 以下是错误设置XmxXms值可能导致的错误列表-

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.原因:只提供了 -Xms 而没有提供 -Xmx。 you will also get this error if you have a typo and instead of -Xmx you have specified -Xms two times如果您有拼写错误并且您指定了 -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 无法启动

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 位为我解决了这个问题。

got the correct parameters(JAVA_OPTS) from here .这里得到正确的参数(JAVA_OPTS)。 I've set them in setenv.bat.我已经在 setenv.bat 中设置了它们。

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")

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 cli java -Xs:64m -Xmx:1g -jar app.jarjava cli java -Xs:64m -Xmx:1g -jar app.jar

On docker-compose.yml example (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"

And in my case reason was to have -Xms option before -javaagent .就我而言,原因是在-javaagent之前有-Xms选项。 Executing it in right order java -javaagent:xxx -Xms256m did the trick.以正确的顺序执行它java -javaagent:xxx -Xms256m成功了。

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.在大多数 32 位 java 版本上,最大堆大小范围从 1.4G 到 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.如果您必须将超过 1.4G 的 JVM 初始化为 1.6G 的堆内存,那么您应该安装 64 位 java 版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM