Skip to content

Commit 9abaf49

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 cb1423d commit 9abaf49

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
@@ -410,11 +410,10 @@ class BuildPlugin implements Plugin<Project> {
410410
project.afterEvaluate {
411411
project.tasks.withType(JavaCompile) {
412412
File gradleJavaHome = Jvm.current().javaHome
413-
if (new File(project.javaHome).canonicalPath != gradleJavaHome.canonicalPath) {
414-
options.fork = true
415-
options.forkOptions.executable = new File(project.javaHome, 'bin/javac')
416-
options.forkOptions.memoryMaximumSize = "1g"
417-
}
413+
// we fork because compiling lots of different classes in a shared jvm can eventually trigger GC overhead limitations
414+
options.fork = true
415+
options.forkOptions.executable = new File(project.javaHome, 'bin/javac')
416+
options.forkOptions.memoryMaximumSize = "1g"
418417
if (project.targetCompatibility >= JavaVersion.VERSION_1_8) {
419418
// compile with compact 3 profile by default
420419
// NOTE: this is just a compile time check: does not replace testing with a compact3 JRE

0 commit comments

Comments
 (0)