Run application via gradlew with -Xmx and -Xms

只谈情不闲聊 提交于 2019-12-03 23:22:05

Add this in your gradle.properties file :

org.gradle.jvmargs=-Xmx2000m

From here

org.gradle.jvmargs

Specifies the jvmargs used for the daemon process. The setting is particularly useful for tweaking memory settings. At the moment the default settings are pretty generous with regards to memory.

edit : my answer what about the gradle daemon jvm, not the app jvm. You have to use the jvmArgs property

The extra arguments to use to launch the JVM for the process. Does not include system properties and the minimum/maximum heap size.

Using application plugin one can use applicationDefaultJvmArgs property

apply plugin: 'application'    
applicationDefaultJvmArgs = ["-Xms1024m", "-Xmx2048m"]

The arguments will be applied to run task and to start script of your application

more info

Firstly, thanks @ToYonos for leading me to the right direction.

Secondly, I found the solution here https://stackoverflow.com/a/9648945/4587961. I ran my app from command line.

set GRADLE_OPTS=-Xms1724m -Xmx5048m
gradlew debug-app

Note, CMD Windows command SET works locally, so if you close your terminal, GRADLE_OPTS will not be set. For Linux, you can use

export GRADLE_OPTS=WHATEVER

This is what I wanted to achieve.

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