Inherit max metaspace size of client VM for Kotlin compile daemon
#KT-32521 In Progress
#KT-32950 Fixed
This commit is contained in:
+10
-7
@@ -187,13 +187,14 @@ fun Iterable<String>.filterExtractProps(vararg groups: OptionsGroup, prefix: Str
|
||||
data class DaemonJVMOptions(
|
||||
var maxMemory: String = "",
|
||||
var maxPermSize: String = "",
|
||||
var maxMetaspaceSize: String = "",
|
||||
var reservedCodeCacheSize: String = "",
|
||||
var jvmParams: MutableCollection<String> = arrayListOf()
|
||||
) : OptionsGroup {
|
||||
|
||||
override val mappers: List<PropMapper<*, *, *>>
|
||||
get() = listOf(StringPropMapper(this, DaemonJVMOptions::maxMemory, listOf("Xmx"), mergeDelimiter = ""),
|
||||
StringPropMapper(this, DaemonJVMOptions::maxPermSize, listOf("XX:MaxPermSize"), mergeDelimiter = "="),
|
||||
StringPropMapper(this, DaemonJVMOptions::maxMetaspaceSize, listOf("XX:MaxMetaspaceSize"), mergeDelimiter = "="),
|
||||
StringPropMapper(this, DaemonJVMOptions::reservedCodeCacheSize, listOf("XX:ReservedCodeCacheSize"), mergeDelimiter = "="),
|
||||
restMapper)
|
||||
|
||||
@@ -279,11 +280,13 @@ fun configureDaemonJVMOptions(opts: DaemonJVMOptions,
|
||||
val targetOptions = if (inheritMemoryLimits) opts else DaemonJVMOptions()
|
||||
val otherArgs = jvmArguments.filterExtractProps(targetOptions.mappers, prefix = "-")
|
||||
|
||||
if (inheritMemoryLimits && opts.maxMemory.isBlank()) {
|
||||
val maxMemBytes = Runtime.getRuntime().maxMemory()
|
||||
// rounding up
|
||||
val maxMemMegabytes = maxMemBytes / (1024 * 1024) + if (maxMemBytes % (1024 * 1024) == 0L) 0 else 1
|
||||
opts.maxMemory = "${maxMemMegabytes}m"
|
||||
if (inheritMemoryLimits) {
|
||||
if (opts.maxMemory.isBlank()) {
|
||||
val maxMemBytes = Runtime.getRuntime().maxMemory()
|
||||
// rounding up
|
||||
val maxMemMegabytes = maxMemBytes / (1024 * 1024) + if (maxMemBytes % (1024 * 1024) == 0L) 0 else 1
|
||||
opts.maxMemory = "${maxMemMegabytes}m"
|
||||
}
|
||||
}
|
||||
|
||||
if (inheritOtherJvmOptions) {
|
||||
@@ -365,7 +368,7 @@ private fun String.memToBytes(): Long? =
|
||||
|
||||
|
||||
private val daemonJVMOptionsMemoryProps =
|
||||
listOf(DaemonJVMOptions::maxMemory, DaemonJVMOptions::maxPermSize, DaemonJVMOptions::reservedCodeCacheSize)
|
||||
listOf(DaemonJVMOptions::maxMemory, DaemonJVMOptions::maxPermSize, DaemonJVMOptions::maxMetaspaceSize, DaemonJVMOptions::reservedCodeCacheSize)
|
||||
|
||||
infix fun DaemonJVMOptions.memorywiseFitsInto(other: DaemonJVMOptions): Boolean =
|
||||
daemonJVMOptionsMemoryProps
|
||||
|
||||
Reference in New Issue
Block a user