如何解决“VM初始化期间发生错误”java?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12889678/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 10:39:05  来源:igfitidea点击:

How to resolve 'Error occurred during initialization of VM' java?

javajvm

提问by Pro.Hessam

I've connected to a linux-based server using ssh. Recently, I've installed JDK using following command:

我已经使用 ssh 连接到基于 linux 的服务器。最近,我使用以下命令安装了 JDK:

sudo yum install java-1.6.0-openjdk-devel

sudo yum install java-1.6.0-openjdk-devel

And jdk installed successfully, but whenever I run command javaor javacI get following error:

并且 jdk 安装成功,但是每当我运行命令java或出现javac以下错误时:

Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

Even, running command java -version, will bring that error. When I try to give java more space using java -Xmx512m -Xms256m -version, I'll get following error:

甚至,运行 command java -version,也会带来该错误。当我尝试使用 给 java 更多空间时java -Xmx512m -Xms256m -version,我会收到以下错误:

*** glibc detected *** java: double free or corruption (!prev): 0x00007fc84400e270 ***
*** glibc detected *** java: double free or corruption (fasttop): 0x00007fc8440089f0 ***
#
Aborted (core dumped)

How can I resolve this?

我该如何解决这个问题?

Thanks in advance

提前致谢

采纳答案by seninp

I have never seen this sort of exception, so it is my best guess: did you try to limit stack size by using -Xss JVM parameter(i.e. -Xms8m -Xmx16m -Xss4m)? Also quick googling suggest that export MALLOC_CHECK_=0could possibly let you get over, but I am not sure if JVM will function well.

我从未见过这种异常,所以这是我最好的猜测:您是否尝试通过使用 -Xss JVM 参数(即 -Xms8m -Xmx16m -Xss4m)来限制堆栈大小?快速谷歌搜索也表明这export MALLOC_CHECK_=0可能会让你克服,但我不确定 JVM 是否能正常运行。

回答by a.k.a Mark

A virtual Linux server? What do you get when run:

虚拟 Linux 服务器?运行时你会得到什么:

java -Xmx1m -version

java -Xmx1m -version

and

ulimit -a

ulimit -a

Looks like a memory allocating problem. You can try to increase swap space if possible.

看起来像内存分配问题。如果可能,您可以尝试增加交换空间。

回答by thedayofcondor

To me it looks like there is not enough memory to run the virtual machine (maybe physical memory, virtual memory or ulimit) - you should try decreasing the memory allocated to the VM (I think the default in 64Mb) and not increasing it.

对我来说,似乎没有足够的内存来运行虚拟机(可能是物理内存、虚拟内存或 ulimit)——您应该尝试减少分配给 VM 的内存(我认为默认为 64Mb)而不是增加它。

回答by Oualid Jabnoune

Lower your -Xms (not xmx).Use -Xms40m for example.If it starts as it is stated in other answers, you may be too low on memory to reclaim 256m for the vm at start.

降低您的 -Xms(不是 xmx)。例如,使用 -Xms40m。如果它按照其他答案中的说明启动,则您的内存可能太低,无法在启动时为 vm 回收 256m。

回答by Anshu

Looks like you are using JDK 32-bit version. If so, you cannnot assign a Heap size more than 1.2GBor something.

看起来您使用的是JDK 32 位版本。如果是这样,您不能分配堆大小超过1.2GB或某事。

Either use a 64 bit JDK or try with 1.2Gas the max heap size.

使用 64 位 JDK 或尝试使用1.2G最大堆大小。