Linux 无法创建Java虚拟机
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9891366/
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
Could not create the Java virtual machine
提问by Uday Sawant
facing some problem with java virtual machine initialization. when i am using root account i can properly work with java. but when i am a user account it returns following errors
面对java虚拟机初始化的一些问题。当我使用 root 帐户时,我可以正常使用 java。但是当我是用户帐户时,它会返回以下错误
user@host# $JAVA_HOME/bin/java -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
It does not seems like a memory issue as the same command works with root account. Available memory (free -m) is more than 1200MB Also i have tried increasing the JVM memory limits
这似乎不是内存问题,因为相同的命令适用于 root 帐户。可用内存(free -m)超过 1200MB 我也试过增加 JVM 内存限制
采纳答案by Uday Sawant
Just be careful. You will get this message if you try to enter a command that doesn't exist like this
小心点。如果您尝试输入一个不存在的命令,您将收到此消息
/usr/bin/java -v
/usr/bin/java -v
回答by theJollySin
I had this issue today, and for me the problem was that I had allocated too much memory:
我今天遇到了这个问题,对我来说问题是我分配了太多内存:
-Xmx1024M -XX:MaxPermSize=1024m
-Xmx1024M -XX:MaxPermSize=1024m
Once I reduced the PermGen space, everything worked fine:
一旦我减少了永久代空间,一切都很好:
-Xmx1024M -XX:MaxPermSize=512m
-Xmx1024M -XX:MaxPermSize=512m
I know that doesn't look like much of a difference, but my machine only has 4GB of RAM, and apparently that was the straw that broke the camel's back. The Java VM was failing immediately upon every action because it was failing to allocate the memory.
我知道这看起来没什么区别,但我的机器只有 4GB 的内存,显然这是压垮骆驼的最后一根稻草。Java VM 在每次操作时都立即失败,因为它无法分配内存。
回答by Uday Sawant
The problem got resolved when I edited the file /etc/bashrc
with same contents as in /etc/profiles
and in /etc/profiles.d/limits.sh
and did a re-login.
当我/etc/bashrc
用与 in/etc/profiles
和 in相同的内容编辑文件/etc/profiles.d/limits.sh
并重新登录时,问题得到了解决。
回答by lashgar
Set the JVM memory:
设置JVM内存:
export _JAVA_OPTIONS=-Xmx512M
export _JAVA_OPTIONS=-Xmx512M
回答by dilip dhiran
Make sure the physical available memory is more then VM defined min/max memory.
确保物理可用内存大于 VM 定义的最小/最大内存。