question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

jvm arguments are not getting applied via command line parameter

See original GitHub issue

I’m trying to profile a build with different -Xmx sizes. I’m using -D<key>=<value>: to override default heap settings. I assume it should work because of isssue https://github.com/gradle/gradle-profiler/issues/101

Unfortunately parameter does not getting applied.

I added jvmArguments logging to ToolingApiInvoker.java runTasks method.

Gradle plugin 5.4.1, MacOS

sampleProfile.scenarios

default-scenarios = ["incremental_build"]

incremental_build {
    tasks = ["assemble"]

    apply-abi-change-to = "app/src/main/java/com/example/myapplication/LongOperation.java"
    daemon = cold // value can be "warm", "cold", or "none"
    clear-build-cache-before = SCENARIO
    clear-transform-cache-before = SCENARIO
    show-build-cache-size = true
    #jvm-args = ["-Xmx2500m"]
}

First try with -D paramter gradle-profiler --benchmark --scenario-file ~/sampleProfile.scenarios --project-dir ~/AndroidStudioProjects/MyApplication/ --output-dir ~/tmp/1 incremental_build -Dorg.gradle.jvmargs="-Xmx2500m"

ToolingApiInoker runtasks() jvmArgs [-Xmx1536m, -Dfile.encoding=UTF-8, -Duser.country=RU, -Duser.language=en, -Duser.variant, -Dorg.gradle.jvmargs=-Xmx2500m, -Dorg.gradle.profiler.scenario=incremental_build, -Dorg.gradle.profiler.phase=WARM_UP, -Dorg.gradle.profiler.number=1, -Dorg.gradle.profiler.step=BUILD] And VisualVM shows that Xmx is default 1536


second try, with jvm-args in scenario gradle-profiler --benchmark --scenario-file ~/sampleProfile.scenarios --project-dir ~/AndroidStudioProjects/MyApplication/ --output-dir ~/tmp/2 incremental_build

ToolingApiInoker runtasks() jvmArgs [-Xmx1536m, -Dfile.encoding=UTF-8, -Duser.country=RU, -Duser.language=en, -Duser.variant, -Xmx2500m, -Dorg.gradle.profiler.scenario=incremental_build, -Dorg.gradle.profiler.phase=WARM_UP, -Dorg.gradle.profiler.number=1, -Dorg.gradle.profiler.step=BUILD] VisualVM shows that Xmx is applied and is Xmx2500m

I want to be able to change jvm arguments dynamically, so I can run script that will find optimal heap/workers combination. Looks like this is not currently possible due to a bug or unsupported feature.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

4reactions
ultraoncommented, Feb 2, 2021

@android10 I see that you use -P in ./gradlew -Porg.gradle.jvmargs=-Xmx16g wrapper, but -P means gradle project property, using -D e.g. ./gradlew -Dorg.gradle.jvmargs=-Xmx16g wrapper means that the property will be used by gradle and jvm. I’ve tried with -D and works well.

0reactions
gabrielfeocommented, Mar 28, 2022

I think this issue can be closed. The replies suggest profiler was re-using daemons from regular ./gradlew builds (not sure this was the behavior before), but the current behavior is profiler uses its own GRADLE_USER_HOME, so it doesn’t share daemons with such builds. It also stops all of its own daemons before benchmarks. Thus I don’t see how this could occur today.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Proper usage of Java -D command-line parameters
I suspect the problem is that you've put the "-D" after the -jar . Try this: java -Dtest="true" -jar myApplication.jar. From the command...
Read more >
Configuring the Default JVM and Java Arguments
Sets the JVM that will be used for the directory server and for all of its command-line utilities, unless a different JVM is...
Read more >
Setting generic JVM arguments in WebSphere Application ...
The generic JVM arguments are used to configure and adjust how the JVM executes. Once changes are made and saved to the master...
Read more >
While deploying to Mule RTF I am setting few jvm arguments ...
There are parameters in deploymentSettings to set values to resources like cpu, ... don't include any hyphens or command line parameter.
Read more >
Include the Java agent with a JVM argument
From the Glassfish console, select Application Server > JVM Settings > JVM Options. On the JVM Options page, select Add JVM Option. Add...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found