Java Out of Memory
Java tends to use a lot of memory. This can cause out-of-memory (OOM) issues inside your jobs with limited resources. We recommend specifying a maximum memory allocation to avoid this error. You can also consider configuring your memory-intensive jobs to run in a larger resource class.
There are a variety of different environment variables you can set to manage memory usage, whether you're using Gradle, Maven, Kotlin, or Lein.
The blog post below can be helpful to guide you in controlling the memory usage of java, depending on the framework that you are using:
Also, consider disabling pre-dexing for your Android builds while in CI