Closed ColtonIdle closed 3 years ago
Thanks for filing. It does look like your build is not picking up the -XX:+UseParallelGC
flag. If you are able to reproduce this in a small sample project that would help.
Can you try removing the \
in front of the colon for the :MaxPerSize
? As well as the other \
in the file that aren't necessary?
Where is this gradle.properties
file located?
I tried removing the slashes. Same issue.
I tried removing all properties and only putting in the GC flag and that didn't work either. Any chance you know if it's possible to somehow print out the args in gradle with some debug optino? I looked last night but couldn't find anything.
This file is located at the root of my project. I have two more gradle.properties files. 1. app module level and 2. a custom view module. I just tried deleting 1 and 2 and only leaving the root, but it still didn't work.
Minimal reproducible app?
File > New Project > Empty Activity Copy over the LEGACY setup from here: https://plugins.gradle.org/plugin/com.osacky.doctor Run build. Fails!
Hooray. It's not just my app!
Here is how the root level build.gradle looks
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.20"
repositories {
google()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.0-alpha02"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.osacky.doctor:doctor-plugin:0.7.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply plugin: "com.osacky.doctor"
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Do you have anything in a gradle.properties
file in your Gradle home? ~/.gradle/gradle.properties
?
Apparently I do! org.gradle.jvmargs=-Xmx8192m
EDIT I don't remember creating that file... but I guess I did a while back. I'm assuming that it overriding everything else...
Jeez... if this is the cause of everything I will be relieved!
Yep! Deleted the file and everything is running smoothly now. @runningcode what would you say is the best place to put this stuff? I assume per project is best so that it shares between the team, but if my machine has more ram, where would I define that?
You should choose the JVM args and heap size that allow the project to be built with no performance bottlenecks. You can check a build scan to see how full the heap size is during the build and how much time is spent garbage collecting. A build should not be spending a significant amount of time garbage collecting. Adding more memory to a build or project which does not have memory pressure does not improve build performance in any way. Therefore I would recommend setting these per project basis.
@runningcode thanks for the insight!
Glad we got to the bottom of this! Closing this out.
I upgraded to the latest version of gradle doctor and was met with a new error:
Add -XX:+UseParallelGC to the org.gradle.jvmargs
This is what I currently have
org.gradle.jvmargs=-Xmx2048M -XX\:MaxPermSize\=4g -XX\:+HeapDumpOnOutOfMemoryError -Dfile.encoding\=UTF-8
I changed it to
org.gradle.jvmargs=-Xmx2048M -XX\:MaxPermSize\=4g -XX\:+HeapDumpOnOutOfMemoryError -Dfile.encoding\=UTF-8 -XX:+UseParallelGC
and it still doesn't work. I am a gradle noob, but this seems like the right spot? This is in the my root gradle.properties file.
Things I tried:
But that doesn't seem right because it reports Xmx as 8192 and I have it set to 2048. So I don't know what is printing out about the instance of java running. Also, I could have sworn I was using jdk 11 not 14. Switching to 11 didn't help things.
Hope to help any way I can.