eclipse 初始化 VM 时发生错误,无法为对象堆保留足够的空间 - Spring Tool Suite?

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

Error occured during initialization of VM, Could not reserve enough space for object heap - Spring Tool Suite?

javaeclipsespringgradlests-springsourcetoolsuite

提问by Yeshwanth Reddy

I'm getting the following error when I build a Gradle project, but SpringToolSuite runs fine

构建 Gradle 项目时出现以下错误,但 SpringToolSuite 运行良好

Error occured during the initialization of VM
Could not reserve enough space for object heap
Error: Could not create Java Virtual Machine
Error: A fatal exception has occurred. Program will exit.

I have 4GB of RAM, My OS is 64-bit and I recently upgraded Java from 1.6 to 1.7

我有 4GB 内存,我的操作系统是 64 位,我最近将 Java 从 1.6 升级到 1.7

And this is my sts.ini

这是我的 sts.ini

 -startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20120522-1813
-product
org.springsource.sts.ide
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
1024M
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms512m
-Xmx768m
-XX:MaxPermSize=1024m

I've tried all sorts of variations of -Xmsand -Xmxand still the same error.

我试过的变化,各种-Xms-Xmx仍然相同的错误。

回答by mtrovo

If your STS is running fine then the problem is with the JVM gradle runs to build your project.

如果您的 STS 运行良好,那么问题在于 JVM gradle 运行以构建您的项目。

If you're using Gradle Wrapper you can configure direct its file, if you want eclipse to override it's params than you can try editing the Gradle preferences under Window > Preferences > Gradle > Argumentswith your custom values for -Xmxand -Xms.

如果你使用的摇篮包装可以配置指导其文件,如果你想日食覆盖它的PARAMS比你可以尝试编辑下的摇篮喜好窗口>首选项>摇篮>参数为您的自定义值-Xmx-Xms

enter image description here

在此处输入图片说明

回答by Piotr Korlaga

You have to go to your main gradle folder where you install Gradle so if you installed Gradle in home directory ex.:

您必须转到安装 Gradle 的主 gradle 文件夹,因此如果您将 Gradle 安装在主目录中,例如:

C:\Users\YourUserName\.gradle\deamon.1

and create there file

并在那里创建文件

gradle.properties

Put into file this:

放入文件:

org.gradle.jvmargs=-Xmx512m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

org.gradle.java.home=C:/Development/Tools/Java/Java7/bin [CHANGE IT TO YOUR PATH TO JAVA_HOME]

回答by sashikanta

I was having same kind of problem. The following solved the problem for me:

我遇到了同样的问题。以下为我解决了这个问题:

Eclipse -> run -> run configuration -> arguments

Eclipse -> 运行 -> 运行配置 -> 参数

and add

并添加

-XX:MaxHeapSize=1024m

-XX:MaxHeapSize=1024m

The size depends on your application's requirement. Hope this will help you. If you are using STS I think you can find the same option as of Eclipse.

大小取决于您的应用程序的要求。希望这会帮助你。如果您使用的是 STS,我认为您可以找到与 Eclipse 相同的选项。

回答by greatest

In android studio I added this line:

在 android studio 中,我添加了这一行:

org.gradle.jvmargs=-Xmx512m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8