首页 > 解决方案 > Gradle 在构建时抛出 OutOfMemoryException

问题描述

我正在尝试设置/克隆现有的 grails 项目。我设法在几台 windows/macos 计算机以及 3-4 台运行 Ubuntu 的服务器(范围从 16.04 到 20.04)上很好地安装了它。但是我租用的最新 vServer 似乎在 gradle-build 方面存在一些问题,因为无论我尝试做什么,它总是抛出 OutOfMemoryException。

我已经尝试增加最大内存大小,允许使用 grails / gradle,但我仍然得到 OutOfMemoryException。我设法将其范围缩小到 gradle,这似乎与没有交换内存的 vServer 有问题 - 这就是我从错误日志中 gradle 告诉我的所有内容中读出的内容:

There is insufficient memory for the Java Runtime Environment to continue. 
Cannot create GC thread. 
Out of system resources. 
Possible reasons: 
- The system is out of physical RAM or swap space

除此之外,我注意到,gradle 在崩溃之前使用了大约 1 到 1.5GB 的内存 - 但我为他分配了高达 6GB 的使用-Xmx6G(请注意,系统有 8GB 可用)

也许这里有人可以帮助我并告诉我我能做些什么来解决这个问题/让圣杯启动并运行(我尝试了我能找到的一切)。

附上我有(失败的)构建的堆栈跟踪:https ://pastebin.com/Kv2c4gu0

提前致谢。

编辑:服务器有 8GB 内存;4个核心;我通过openjdk 8 Gradle安装Java 1.8.0_252应该是4.4.1版本 Grails是用4.0.1版本安装的

标签: gradlegrailsout-of-memoryubuntu-18.04

解决方案


问题已解决:vServer有0b的swap-storage,导致gradle/grails抛出内存不足的错误。

我需要做的就是创建一个交换分区来编译 gradle。


推荐阅读