简体   繁体   English

“虚拟机初始化时出错; 无法为对象堆保留足够的空间”使用 -Xmx3G

[英]“Error occurred during initialization of VM; Could not reserve enough space for object heap” using -Xmx3G

First of all, I have a box with 8gb of ram, so I doubt total memory is the issue.首先,我有一个装有 8GB 内存的盒子,所以我怀疑总内存是问题所在。 This application is running fine on machines with 6gb or less.此应用程序在 6GB 或更少的机器上运行良好。

I am trying to reserve 3GB of space using -Xmx3G under "VM Arguments" in Run Configurations in Eclipse.我试图在 Eclipse 中运行配置中的“VM 参数”下使用 -Xmx3G 保留 3GB 空间。

Every time I try to reserve more than 1500mb, I get this error: “Error occurred during initialization of VM;每次尝试保留超过 1500mb 时,都会收到此错误消息:“VM 初始化期间发生错误; Could not reserve enough space for object heap” using -Xmx3G无法为对象堆保留足够的空间”使用 -Xmx3G

What is going on here?这里发生了什么?

可能是您在那台机器上使用了 32 位 jvm?

Here is how to fix it: Go to Start->Control Panel->System->Advanced(tab)->Environment Variables->System修复方法如下:转到Start->Control Panel->System->Advanced(tab)->Environment Variables->System

Variables->New:
Variable name: _JAVA_OPTIONS   
Variable value: -Xmx512M

Variable name: Path  
Variable value: ;C:\Program Files\Java\jre6\bin;F:\JDK\bin;  

Change this to your appropriate path .将此更改为您的适当路径

This is actually not an Eclipse-specific issue;这实际上不是特定于 Eclipse 的问题; it's a general Java-on-Windows issue.这是一个普遍的 Java-on-Windows 问题。 It's because of how the JVM allocates memory on Windows;这是因为 JVM 在 Windows 上分配内存的方式; it insists on allocating a contiguous chunk of memory, which often Windows can't provide, even if there are enough separate chunks to satisfy the allocation request.它坚持分配一个连续的内存块,即使有足够的单独的块来满足分配请求,Windows 通常也无法提供。 There are utilities that will try to help Windows "defrag" its memory, which would, in theory, help this situation;有一些实用程序会尝试帮助 Windows 对其内存进行“碎片整理”,理论上可以帮助解决这种情况; but I've not really tried them in earnest so can't speak to their effectiveness.但我还没有真正认真地尝试过它们,所以不能说它们的有效性。 One thing that I've heard sometimes that might help is to reboot Windows and, before starting any other apps, launch the Java app that needs the big chunk of memory.我有时听到的一件事可能有帮助,那就是重新启动 Windows,然后在启动任何其他应用程序之前,启动需要大量内存的 Java 应用程序。 If you're lucky, Windows won't have fragmented its memory space yet and Java will get the contiguous block that is asks for.如果幸运的话,Windows 还没有对其内存空间进行碎片化,而 Java 将获得所要求的连续块。

Somewhere out on the interwebs there are more technical explanations and analyses of this issue, but I don't have any references handy.在互联网上的某个地方有更多关于这个问题的技术解释和分析,但我没有任何参考资料。

I did find this, though, which looks helpful: https://stackoverflow.com/a/497757/639520不过,我确实发现了这一点,这看起来很有帮助: https : //stackoverflow.com/a/497757/639520

First the JRE of 32bits can't use more ~1.5Gb of ram.首先 32 位的 JRE 不能使用更多 ~1.5Gb 的内存。 So if you want more, use a 64bits JRE.因此,如果您想要更多,请使用 64 位 JRE。

Second, When a new JVM starts, this sum the -Xmx property of the all JVM that are running, and check if there is enough memory left on the system to run at their own -Xmx, if is not enough then the error occurs.其次,当一个新的 JVM 启动时,这个和所有正在运行的 JVM 的 -Xmx 属性相加,并检查系统上是否有足够的内存可以在自己的 -Xmx 上运行,如果不够则发生错误。

I was using Liferay with Tomcat server from eclipse IDE.我在 Eclipse IDE 中使用 Liferay 和 Tomcat 服务器。 I was stuck with this same error on click on server start up.单击服务器启动时,我遇到了同样的错误。 Double click on server from eclipse.在 Eclipse 中双击服务器。 it open up Server Overview page.它打开服务器概述页面。 Updated memory arguments from -Xmx1024m -XX:MaxPermSize=256m to -Xmx512m -XX:MaxPermSize=256m.将内存参数从 -Xmx1024m -XX:MaxPermSize=256m 更新为 -Xmx512m -XX:MaxPermSize=256m。 Then it was working for me.然后它对我有用。

Make sure that Eclipse is actually running the same JVM you think it's running.确保 Eclipse 实际运行的 JVM 与您认为它运行的 JVM 相同。 If you use java in your web browser ever, you likely have a 32-bit version floating around too that might be taking precedence if it installed or updated lately.如果您曾经在 Web 浏览器中使用 Java,那么您可能也有一个 32 位版本,如果它最近安装或更新,它可能会优先。

To be absolutely sure, I recommend adding these two lines to your eclipse.ini file at the top:为了绝对确定,我建议将这两行添加到顶部的eclipse.ini文件中:

-vm 
C:/Java/jdk1.6.0_27/bin

...where on my machine C:/Java/jdk1.6.0_27/bin where the JVM I know is 64-bit is located. ...在我的机器C:/Java/jdk1.6.0_27/bin上,我知道 64 位 JVM 所在的位置。 Be sure to have the bin folder there.确保那里有bin文件夹。

(As a bonus, on Windows 7, this also allows you to actually "pin the tab" which is why I had to do this for my own usage) (作为奖励,在 Windows 7 上,这也允许您实际“固定选项卡”,这就是为什么我必须这样做以供我自己使用)

This is the issue of Heap size.这是堆大小的问题。 Edit your .bat (Batch file).编辑您的.bat (批处理文件)。 It might be showing Heap size 1024. Change it to 512 Then it should work.它可能显示堆大小 1024。将其更改为 512 然后它应该可以工作。

I also had the same problem while using Eclipse which was 32 bit and the JVM used by it was 64 bit.我在使用 Eclipse 时也遇到了同样的问题,它是 32 位的,它使用的 JVM 是 64 位。 When I routed the Eclipse to 32 bit JVM then it worked当我将 Eclipse 路由到 32 位 JVM 时,它就起作用了

只需在org.gradle.jvmargs=-Xmx1536m中的org.gradle.jvmargs=-Xmx1536m前面加上#符号

 # org.gradle.jvmargs=-Xmx1536m

I know that i am a bit late, but here my answer comes:我知道我有点晚了,但我的答案来了:

I just installed the Java online Version from Oracle(not the offline 64-Bit one).我刚刚从 Oracle 安装了 Java 在线版本(不是离线 64 位版本)。

After having added the JAVA_HOME ENV variable, it just worked!添加 JAVA_HOME ENV 变量后,它就起作用了!

Hope I could help :)希望我能帮上忙:)

Probably you are trying wrong options anyways.无论如何,您可能正在尝试错误的选择。 I got a similar error with supporting error log:我在支持错误日志时遇到了类似的错误:

Java HotSpot(TM) Client VM warning: ignoring option PermSize=32M; support was removed in 8.0
Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=128M; support was removed in 8.0

Im my case, the software did not support java 8 yet(script was using old JVM arguments) but I had had java 8 by default.我的情况是,该软件尚不支持 java 8(脚本使用旧的 JVM 参数),但默认情况下我有 java 8。

One of the reason for this issue is no memory available for Tomcat to start.此问题的原因之一是 Tomcat 没有可用的内存来启动。 Try to delete the unwanted running software from windows and restart the eclipse and tomcat.尝试从windows中删除不需要的正在运行的软件并重新启动eclipse和tomcat。

Solution is simple.解决方法很简单。 No need to go deep into this issue.无需深入探讨这个问题。

If you are running on 64bit machine then follow below steps:如果您在64 位机器上运行,请按照以下步骤操作:

  • Unistall 32 bit java first (check in C:\\Program Files (x86) for its existence)首先卸载 32 位 java(检查 C:\\Program Files (x86) 是否存在)
  • Install the newer version JDK kit 64 bit (includes JRE)安装较新版本的 JDK 工具包 64 位(包括 JRE)
  • Set the environment path (To avoid conflict error if you have two different 64bit JRE)设置环境路径(如果你有两个不同的 64 位 JRE,为了避免冲突错误)
  • Check in command prompt by typing javac command.通过键入 javac 命令签入命令提示符。
  • Restart / Done重启/完成

You can have two different Java installed but don't forgot to set path.您可以安装两个不同的 Java,但不要忘记设置路径。

请在环境变量中设置JAVA_OPTS=-Xms256m -Xmx512m ,它应该可以解决问题,它对我有用

暂无
暂无

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

相关问题 VM初始化期间发生错误; 无法为对象堆保留足够的空间; 无法创建Java虚拟机 - Error occurred during initialization of VM; Could not reserve enough space for object heap; Could not create the Java virtual machine VM 初始化过程中发生错误 无法为对象堆保留足够的空间 无法创建 Java 虚拟机 - Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine VM 初始化时出错 无法为 object 堆 Android Studio 保留足够的空间 - Error occurred during initialization of VM Could not reserve enough space for object heap Android Studio 初始化 VM 时出错,无法为 object 堆预留足够的空间 - Error occurred during initialization of VM, Could not reserve enough space for object heap 解决方法:“ VM初始化期间发生错误; 无法为对象堆保留足够的空间” - How to resolve this : “Error occurred during initialization of VM; Could not reserve enough space for object heap” VM初始化期间发生错误,无法为对象堆保留足够的空间 - Error occurred during initialization of VM Could not reserve enough space for object heap “ VM初始化期间发生错误,无法为1048576KB对象堆保留足够的空间” - “Error occurred during initialization of VM Could not reserve enough space for 1048576KB object heap” VM初始化期间发生Java错误无法为对象堆保留足够的空间 - Java Error occurred during initialization of VM Could not reserve enough space for object heap 初始化VM时出错,无法为对象堆保留足够的空间 - Spring Tool Suite? - Error occured during initialization of VM, Could not reserve enough space for object heap - Spring Tool Suite? VM初始化期间发生错误:无法为对象堆保留足够的空间 - Error occured during initialization of VM: Could not reserve enough space for object heap
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM