https://kotlinlang.org logo
#gradle
Title
# gradle
e

Eugen Martynov

10/24/2023, 12:07 PM
I converted build gradle to kotlin script and started seen on CI failures
Copy code
The message received from the daemon indicates that the daemon has disappeared.
From the past I remember it is probably due to memory limit. I’m trying to revamp all memory parameters for gradle and kotlin for the build.
k

kaeawc

10/24/2023, 12:45 PM
Yeah kotlin script generally takes more memory
What are your current jvm args and Gradle properties?
e

Eugen Martynov

10/24/2023, 1:41 PM
Looks like we have
-Xmx2048m
only
No kotlin daemon specification at all so it takes default from gradle availble
k

kaeawc

10/24/2023, 2:05 PM
I'd try bumping that to 3g or 4g
e

Eugen Martynov

10/24/2023, 2:26 PM
The project runs on the bitbucket pipelines, looks like the pipeline memory is out
k

kaeawc

10/24/2023, 2:27 PM
How big is the instance it's running on?
e

Eugen Martynov

10/24/2023, 2:27 PM
Haha, the bitbucket documentation is not super clear - searching it
k

kaeawc

10/24/2023, 2:28 PM
You might try some other things to reduce memory usage like jemalloc or tcmalloc, upgrade Gradle and AGP to latest
e

Eugen Martynov

10/24/2023, 2:28 PM
We have the latest stable
k

kaeawc

10/24/2023, 2:29 PM
AGP 8.2.x has less memory issues than 8.1 IIRC
Other than that... Gradle remote cache helps a lot
And config cache, though that's hard to get working
But doesn't sound like it's a super big project yet
e

Eugen Martynov

10/24/2023, 2:31 PM
No, quite small in terms of screens but super heavy on the resources (feels like a game).
The remote cache is not affordable for this scale. I have enabled and made it working - cache and configuration cache.
k

kaeawc

10/24/2023, 2:33 PM
Nice
e

Eugen Martynov

10/24/2023, 2:34 PM
Haha, it is one module-app and not many plugins so it was quite easy
I found this in documentation
Copy code
The relevant memory limits and default allocations are as follows:

Regular steps have 4096 MB of memory in total, large build steps (which you can define using size: 2x) have 8192 MB in total.

The build container is given 1024 MB of the total memory, which covers your build process and some Pipelines overheads (agent container, logging, etc).

The total memory for services on each pipeline step must not exceed the remaining memory, which is 3072/7128 MB for 1x/2x steps respectively.

Service containers get 1024 MB memory by default, but can be configured to use between 128 MB and the step maximum (3072/7128 MB).

The Docker-in-Docker daemon used for Docker operations in Pipelines is treated as a service container, and so has a default memory limit of 1024 MB. This can also be adjusted to any value between 128 MB and 3072/7128 MB by changing the memory setting on the built-in docker service in the definitions section.
I’m not fluent with the bitbucket, but I do run CI with docker image
I’m trying to understand now if it means by default I have 1G memory or still 4G and if it is 4G, does it mean I have actually 3G because one is gone for the build container.
k

kaeawc

10/24/2023, 2:39 PM
Whatever you set it to is what Gradle daemon takes
1
You might also want to set the heap for Kotlin jvm
Talking to Gradle about it they generally recommend they both be the same size heap
The oom errors don't typically indicate which daemon fails
e

Eugen Martynov

10/24/2023, 2:45 PM
Thanks!
2 Views