Could not create the Java virtual machine

2020-05-29 16:23发布

问题:

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

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

回答1:

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



回答2:

Set the JVM memory:

export _JAVA_OPTIONS=-Xmx512M



回答3:

I had this issue today, and for me the problem was that I had allocated too much memory:

-Xmx1024M -XX:MaxPermSize=1024m

Once I reduced the PermGen space, everything worked fine:

-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.



回答4:

Make sure the physical available memory is more then VM defined min/max memory.



回答5:

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.



标签: java linux jvm