Launching an application through gradlew with -Xmx and -Xms

I have an application. I run it through

gradlew run-app 

Or debug

 gradlew debug-app 

It works. How to pass the argument "-Xmx" to the application that I run (debug)? Is it possible to do this without editing the build.gradle file?

I found this gradle unknown command line option '-X'

I get a similar error when trying

 gradlew debug-app -Xmx2000m 

Error

 FAILURE: Build failed with an exception. * What went wrong: Problem configuring task :debug-app from command line. > Unknown command-line option '-X'. 

I tried to create a gradle.properties file in the gradle.properties directory (the default is USER_HOME / .gradle).

 org.gradle.jvmargs=-XX\:MaxHeapSize\=4256m -Xmx4256m -Xms2000m 

I also tried org.gradle.jvmargs=-Xmx2000m in the project folder gradle.properties .

And even when I launch the application, I see that the size of Commited Memory is <520 MiB

enter image description here

And this is when I run it as a regular Java application

enter image description here

In the second case, when I run the application as a regular Java application with -Xms, -Xmx, the Commited Memory size is about 3.5 GB, because I passed the parameters -Xmx4512m -Xms2512m .

+5
source share
2 answers

Firstly, thanks @ToYonos for taking me in the right direction.

Secondly, I found a solution here fooobar.com/questions/159399 / .... I launched the application from the command line.

 set GRADLE_OPTS=-Xms1724m -Xmx5048m gradlew debug-app 

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

 export GRADLE_OPTS=WHATEVER 

This is what I wanted to achieve.

enter image description here

+2
source

Add this to your gradle.properties file:

 org.gradle.jvmargs=-Xmx2000m 

From here

org.gradle.jvmargs

Defines jvmargs used for the daemon process. Tuning is especially useful for tuning memory settings. At the moment, the default settings are quite generous with respect to memory.

edit: my answer is, what about the gradle jvm daemon, not the jvm application. You must use the jvmArgs property

Additional arguments to start the JVM for the process. Does not include system properties and minimum / maximum heap size.

+1
source

Source: https://habr.com/ru/post/1269113/


All Articles