Properly limit heap size for gradle child processes
MODIFY
.circleci/config.yml
.circleci/config.yml
@@ -25,7 +25,7 @@ jobs:
- run:
name: Build Project
- command: GRADLE_OPTS="-Dorg.gradle.jvmargs=-Xmx1G -Xms64M" ./gradlew clean :dd-java-agent:shadowJar compileTestGroovy compileTestScala compileTestJava --build-cache --parallel --stacktrace --no-daemon --max-workers=8
+ command: GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx1G -Xms64M' -Ddatadog.forkedMaxHeapSize=1G -Ddatadog.forkedMinHeapSize=64M" ./gradlew clean :dd-java-agent:shadowJar compileTestGroovy compileTestScala compileTestJava --build-cache --parallel --stacktrace --no-daemon --max-workers=8
- run:
name: Collect Libs
@@ -66,7 +66,7 @@ jobs:
- run:
name: Run Tests
- command: GRADLE_OPTS="-Dorg.gradle.jvmargs=-Xmx4G -Xms512M" ./gradlew $TEST_TASK --build-cache --parallel --stacktrace --no-daemon --max-workers=6
+ command: GRADLE_OPTS="-Ddatadog.forkedMaxHeapSize=4G -Ddatadog.forkedMinHeapSize=64M" ./gradlew $TEST_TASK --build-cache --parallel --stacktrace --no-daemon --max-workers=6
- run:
name: Collect Reports
@@ -162,7 +162,7 @@ jobs:
- run:
name: Build Project
- command: GRADLE_OPTS="-Dorg.gradle.jvmargs=-Xmx4G -Xms64M" ./gradlew check -PskipTests --build-cache --parallel --stacktrace --no-daemon --max-workers=8
+ command: GRADLE_OPTS="-Ddatadog.forkedMaxHeapSize=4G -Ddatadog.forkedMinHeapSize=64M" ./gradlew check -PskipTests --build-cache --parallel --stacktrace --no-daemon --max-workers=8
- run:
name: Collect Reports
@@ -184,7 +184,7 @@ jobs:
- run:
name: Verify Version Scan
- command: GRADLE_OPTS="-Dorg.gradle.jvmargs=-Xmx4G -Xms64M" ./gradlew verifyVersionScan --parallel --stacktrace --no-daemon --max-workers=8
+ command: GRADLE_OPTS="-Ddatadog.forkedMaxHeapSize=4G -Ddatadog.forkedMinHeapSize=64M" ./gradlew verifyVersionScan --parallel --stacktrace --no-daemon --max-workers=8
- save_cache:
key: dd-trace-java-version-scan-{{ checksum "dd-trace-java.gradle" }}
@@ -205,7 +205,7 @@ jobs:
# Note: we do not have `--max-workers` here to have number of workers (threads) equal to number of CPUs (32 currently).
# This should speed things up slightly because muzzle may do a lot of IO bound work: reading off disk and downloading
# dependencies.
- command: SKIP_BUILDSCAN="true" GRADLE_OPTS="-Dorg.gradle.jvmargs=-Xmx8G -Xms64M" ./gradlew muzzle --parallel --stacktrace --no-daemon
+ command: SKIP_BUILDSCAN="true" GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx8G -Xms64M' -Ddatadog.forkedMaxHeapSize=4G -Ddatadog.forkedMinHeapSize=64M" ./gradlew muzzle --parallel --stacktrace --no-daemon
- save_cache:
key: dd-trace-java-muzzle-{{ checksum "dd-trace-java.gradle" }}

MODIFY
dd-trace-java.gradle
dd-trace-java.gradle
@@ -55,3 +55,10 @@ ext.gradleWrapperVersion = '4.10.2'
task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}
+
+allprojects {
+ tasks.withType(JavaForkOptions) {
+ maxHeapSize = System.properties["datadog.forkedMaxHeapSize"]
+ minHeapSize = System.properties["datadog.forkedMinHeapSize"]
+ }
+}

MODIFY
gradle/java.gradle
gradle/java.gradle
@@ -267,3 +267,4 @@ plugins.withType(BasePlugin) {
otherTasks*.mustRunAfter deleteTasks
}
}
+

Properly limit heap size for gradle child processes