Java 无效的最大堆大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25190728/
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
Java Invalid maximum heap size
提问by Yss
I just installed Ubuntu 64Bit on my VServer and JRE build 1.7.0_67-b01. If I want to run a java jar-file it says
我刚刚在我的 VServer 和 JRE build 1.7.0_67-b01 上安装了 Ubuntu 64Bit。如果我想运行一个 java jar 文件,它会说
Invalid maximum heap size: -Xmx Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.
无效的最大堆大小:-Xmx 错误:无法创建 Java 虚拟机。错误:发生了致命异常。程序将会退出。
java -help says
java -help 说
java version "1.7.0_67" Java(TM) SE Runtime Environment (build 1.7.0_67-b01) Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
java 版本“1.7.0_67”Java(TM) SE 运行时环境(构建 1.7.0_67-b01)Java HotSpot(TM) 64 位服务器 VM(构建 24.65-b04,混合模式)
I tried 1M, 256M, 1024M, 2G and 4G for -Xmx, nothing works. Is there a hidden setting I don't know?
我为 -Xmx 尝试了 1M、256M、1024M、2G 和 4G,但没有任何效果。有我不知道的隐藏设置吗?
Here's the command I use:
这是我使用的命令:
java -Xmx 1024M -Xms 1024M -jar MyConverter.jar
回答by Xabster
Remove the space after Xmx and Xms
去掉 Xmx 和 Xms 后的空格
回答by Anand Kulkarni
Check your RAM of machine. xmx shout be half of your RAM. Also, xms is jvm heap size at starting whereas xmx is maximum heap size during jvm life cycle. It also depends on how much memory your application going to take during execution.
检查机器的 RAM。xmx 大喊是你内存的一半。此外,xms 是启动时的 jvm 堆大小,而 xmx 是 jvm 生命周期中的最大堆大小。它还取决于您的应用程序在执行期间将占用多少内存。
回答by astef
I had a case related with incompatible line ending between Windows an Linux. So, if nothing helps, be sure your don't copied file from Windows.
我有一个与 Windows 和 Linux 之间不兼容的行尾相关的案例。因此,如果没有任何帮助,请确保您不要从 Windows 复制文件。