Skip to content

Commit d92b6a1

Browse files
committed
Build: Fork javac to avoid GC overhead (#26047)
Compiling all of elasticsearch classes in one jvm, which is shared with all of the loaded classes of gradle, can trip gc overhead limits. This commit re-enables forking javac.
1 parent b7c6623 commit d92b6a1

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,10 @@ class BuildPlugin implements Plugin<Project> {
409409
project.afterEvaluate {
410410
project.tasks.withType(JavaCompile) {
411411
File gradleJavaHome = Jvm.current().javaHome
412-
if (new File(project.javaHome).canonicalPath != gradleJavaHome.canonicalPath) {
413-
options.fork = true
414-
options.forkOptions.executable = new File(project.javaHome, 'bin/javac')
415-
options.forkOptions.memoryMaximumSize = "1g"
416-
}
412+
// we fork because compiling lots of different classes in a shared jvm can eventually trigger GC overhead limitations
413+
options.fork = true
414+
options.forkOptions.executable = new File(project.javaHome, 'bin/javac')
415+
options.forkOptions.memoryMaximumSize = "1g"
417416
if (project.targetCompatibility >= JavaVersion.VERSION_1_8) {
418417
// compile with compact 3 profile by default
419418
// NOTE: this is just a compile time check: does not replace testing with a compact3 JRE

0 commit comments

Comments
 (0)