Gradle构建错误:内存不足 [英] Gradle build error: insufficient memory
问题描述
当我使用gradle构建时,失败并显示信息:
When I build with gradle, it failed with info:
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000788800000, 89128960, 0) failed; error='无法分配内存' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 89128960 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /tmp/jvm-27885/hs_error.log
:app:transformClassesWithDexForBaiduDebug FAILED
:app:transformClassesWithDexForBaiduDebug (Thread[main,5,main]) completed. Took 25.305 secs.
系统内存还剩1G,我认为足够了:
The system memory has 1G left, I think this is enough:
Mem: 3921316k total, 2735992k used, 1185324k free, 14464k buffers
Swap: 0k total, 0k used, 0k free, 90224k cached
添加我在gradle.properties中添加了一些参数,但是没有用:
Add I added some params into gradle.properties but not worked:
org.gradle.jvmargs=-Xms256m -Xmx1024m
还有其他方法可以解决此内存问题吗?
Is there any other way to fix this memory issue?
[已解决]更新物理内存并通过构建后.
[RESOLVED] After update the physical memory and build passed.
推荐答案
在Windows上,当我增加分页文件时,它就像魅力一样工作.
On Windows, for me it worked like charm when I increased my Paging File.
转到:控制面板->系统和安全性->系统->高级系统设置.如果可以的话,给它10-20 GB的硬盘驱动器作为分页内存.
Go to : Control Panel -> System and Security -> System -> Advanced System Settings. Give it 10-20 GB of your hard drive as paging memory if you can.
这篇关于Gradle构建错误:内存不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!