How to limit DEX memory usage

北城以北 提交于 2019-12-22 06:23:38

问题


I am trying to set the maximum memory that DEX task can use in a gradle-based Android project, but can't find any option to do that.

My motivation to do this is because as dex sometimes takes so much memory that my computer starts swapping and becomes completely unresponsive for some minutes (so I would rather see the task fail and then free some more resources and retry)

In my gradle.properties I have org.gradle.jvmargs="-Xmx300m" which limits the memory used by Gradle itself, but when Gradle starts dx it always uses -Xmx1024.

So how can I make Gradle limit the memory used by dx?


回答1:


In your build.gradle script, set the dexOptions.javaMaxHeapSize configuration to whatever value you need:

android {
//snip
//add this into your existing 'android' block
    dexOptions {
        javaMaxHeapSize "4g"
    }
//snip
}

Source



来源:https://stackoverflow.com/questions/26378413/how-to-limit-dex-memory-usage

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!