Nick Kleban
04/02/2024, 2:02 PMgradle.properties
'org.gradle.jvmargs=-Xmx3072m -XX:+UseParallelGC -Dfile.encoding=UTF-8'
• First one takes way more, usually around 4,5GbSam
04/02/2024, 2:14 PMNick Kleban
04/02/2024, 2:22 PM./gradlew clean koverVerify --no-build-cache --no-daemon
Sam
04/02/2024, 2:24 PM--no-daemon
.Sam
04/02/2024, 2:25 PMNick Kleban
04/02/2024, 2:31 PM--no-daemon
I’ve added just for testing, so I don’t need to stop gradle before my test run
When I ran assemble
result is roughly the same
The reason I want to limit it because on CI (14GB RAM) my builds are failing sometimes with OOM, and I suspect this unlimited process may consume too much memorySam
04/02/2024, 2:33 PMSam
04/02/2024, 2:35 PMSam
04/02/2024, 2:35 PMSam
04/02/2024, 2:35 PMSam
04/02/2024, 2:36 PMNick Kleban
04/02/2024, 2:39 PMChrimaeon
04/02/2024, 3:20 PMChrimaeon
04/02/2024, 3:21 PMJAVA_TOOL_OPTIONS: "-Xmx3G"
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.parallel=false -Dorg.gradle.workers.max=2 -Dkotlin.compiler.execution.strategy=in-process -Dkotlin.incremental=false"
and my builds run on a large resource class with 8GB of ram.tapchicoma
04/02/2024, 3:52 PMWhy I see 2 java processes while executing gradle commands? And is it possible to limit memory consumption of second java process?Second process is Kotlin daemon. You could define jvm args for it via
kotlin.daemon.jvmargs
Gradle propertyNick Kleban
04/02/2024, 4:03 PM-Dkotlin.daemon.jvm.options=-Xmx3G
Nick Kleban
04/03/2024, 2:56 PMkotlin.daemon.jvmargs=-Xmx4G -Xms2G
are not honored if gradle daemon was enabled and works perfectly otherwise. Does anyone have any ideas as to why?tapchicoma
04/03/2024, 5:23 PM--no-daemon
option. Why do you think it is not honored?
cc @Alexander.LikhachevAlexander.Likhachev
04/03/2024, 5:37 PMkotlin.daemon.jvmargs=-Xmx4G -Xms2G
> are not honored if gradle daemon was enabled and works perfectly otherwise
Hm, could you explain it more or maybe even provide a reproducer project, please?
In some cases, the Kotlin daemon may reuse the daemon process that was started earlier. It has special handling for the case e.g. if you request 2GB, but there’s already a daemon started for another project that requested 5GB. Then, instead of starting 2 daemons the daemon with the biggest memory limit will be reused. It’s not yet properly documented and sometimes may work not as expected, we have plans to improve this. Thus, if you’re experimenting with different memory limits, sometimes you have to kill the daemon (or use --no-daemon
) during the experiments.Nick Kleban
04/06/2024, 3:53 PMgradle --stop
. I was probably misinterpreting output of top -o mem
command. I’m not sure then what the column mem
shows in this case.Alexander.Likhachev
04/09/2024, 7:47 PMmem
in the output of top
shows the physical memory currently allocated by OS to the JVM process.
Could you provide more specific details about the output you are seeing? Is it lesser than you’re setting? Bigger? You may be also interested in more specialized tools for JVM like jcmd <pid> GC.heap_info
, jcmd <pid> VM.flags
where you can find the required process id using the jps
tool. Or you may even use visual tools like VisualVM or the one included into IDEA Ultmate
By setting -Xmx
, you’re limiting only the heap memory of JVM, it does not say anything about the JVM non-heap memory as well as the metaspace