Skip to content

Commit

Permalink
Decrease memory for Kotlin Daemons and Gradle Daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
osipxd committed Nov 21, 2024
1 parent c9f58b1 commit ada0ba8
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2014-2020 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
# Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
#

# sytleguide
Expand All @@ -8,10 +8,34 @@ kotlin.code.style=official
# config
version=3.0.2-SNAPSHOT

## JVM arguments
#
# Notes:
# * You can reduce '-Xmx' downto '6g' or even '4g', but this could lead to OOM on project sync in an IDE
# while it might be enough for other tasks.
# * '-Dkotlin.daemon.jvm.option' is used for the Kotlin Daemon started by Gradle to compile buildSrc as it ignores
# the value from 'kotlin.daemon.jvmargs'
# * We cannot specify default '-XX:MaxMetaspaceSize' value as it could lead to "OutOfMemory: Metaspace" problems
# on running BCV tasks. While it is okay to set this value on CI.
# See: https://github.com/Kotlin/binary-compatibility-validator/issues/282
#
# On CI it is recommended to add the following options:
# * '-XX:MaxMetaspaceSize=1g'
# To prevent Gradle Daemon from being killed due to unbounded usage of metaspace.
# See: https://github.com/gradle/gradle/issues/19750
# Value '1g' should be enough if you aren't going to run BCV tasks, otherwise use higher value: 2g-4g
# The acceptible maximum depends on the number of Gradle workers that are run in parallel. The more workers,
# the more metaspace memory is consumed.
# * Reduce '-Dkotlin.daemon.options=autoshutdownIdleSeconds' value to '30'
# To save some memory, shutting down Kotlin Daemon used for buildSrc compilation after 30 seconds of idle.
# See: https://github.com/gradle/gradle/issues/29331
#
org.gradle.jvmargs=-Xms2g -Xmx8g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options=-Xmx512m,Xms256m,-XX:MaxMetaspaceSize=256m,XX:+HeapDumpOnOutOfMemoryError -Dkotlin.daemon.options=autoshutdownIdleSeconds=1800
kotlin.daemon.jvmargs=-Xms512m -Xmx2g -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError

# gradle
org.gradle.daemon=true
org.gradle.caching=true
org.gradle.jvmargs=-Xmx10g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC
org.gradle.parallel=true

# kotlin
Expand All @@ -26,8 +50,6 @@ kotlin.apple.xcodeCompatibility.nowarn=true
kotlin.suppressGradlePluginWarnings=IncorrectCompileOnlyDependencyWarning
#kotlinx.atomicfu.enableJvmIrTransformation=true
#kotlinx.atomicfu.enableNativeIrTransformation=true

kotlin.daemon.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError
kotlin.daemon.useFallbackStrategy=false

# dokka
Expand Down

0 comments on commit ada0ba8

Please sign in to comment.