Running out of Java heap size when running tests with coverage

Answered

I am working on a Spring/Kotlin application, using IntelliJ IDEA 2025.2.3 (Ultimate Edition) on Ubuntu 24.04.3 LTS. It is a Gradle project using Java 21. The whole suit is 4.7+k unit tests, as we are extensively making use of parametrized tests, with enums counting tens or hundreds of members as sources.

When running unit tests with coverage, one or two random tests fail with “out of memory” errors related to the Java heap space. At the end, I do get the request to add the new data to the suite or to replace it, but the gutter still shows no code coverage. Some tests are more likely to fail than other ones, but it is still quite random. Running the tests without coverage goes smoothly.
I did not notice the issue happening before, maybe because I did not run tests with coverage very often. But we recently added several new parametrized tests.

I tried increasing the memory heap size in the IDE (Help → Change Memory Settings) to 8 GB, and in the compiler (Settings → Build, Execution, Deployment → Compiler) to 8 GB, with no changes. How can I solve it on my machine? Is this the symptom of problems in my application or in the test suite setup

Exception in thread "HikariPool-1 housekeeper" java.lang.OutOfMemoryError: Java heap space
Exception in thread "scheduling-1" java.lang.OutOfMemoryError: Java heap space

Thanks!

Andrea

1
8 comments

Hi Andrea,

Can you attach a screenshot of your current settings in Settings → Build, Execution, Deployment → Compiler?

Please also provide IDE logs for analysis (entire archive): Help | Collect Logs and Diagnostic Data. I will check the exceptions and your system environment settings more closely.

Logs can be uploaded securely to https://uploads.jetbrains.com. Make sure to share the ID of the upload here so that I can find it.

0

Hi Arina,

Sure! The upload id is 2025_10_15_FWSnVYS6KxJwgNBhJP7H2i (file: idea-logs-20251015-1322068722902872431081504.zip). Here is the screenshot:

Greetings,

Andrea

0

Hi Andrea, thanks for the logs!

Could you try specifying 8000 in the ‘User-local VM options’ field, restarting the IDE and reproducing the problem again?

Also, for testing purposes, please temporarily disable ALL non-bundled plugins: File | Settings | Plugins | ⚙ | Disable all downloaded plugins

0

Hi Arina!

A couple of tests are mostly affected. One is testing an authentication token retrieval, using MockWebServer. The other is testing a function and using an enum with hundreds of elements as source.

I made a few more tries with running unit tests with coverage, tweaking one setting or another in succession:

- Switch to the master branch: Unit tests complete successfully

- Then, switch back to my development branch: Unit tests failing

- Then, set User-local VM options to 8000: Unit tests failing

- Then, disable all non-embedded plug ins: all tests pass

- Then, enable embedded and (most of the) Jetbrains plug ins: One unit test hangs without failing

- Then, set User-local VM options to 24000: Unit tests failing

 

I will be too busy until the end of the week for further checks. I will try narrowing my search down to an offending plugin next week.

Would you make any use of additional logs, in the meantime?

0
Have you tried increasing the memory from the VM Options of the run configuration also(Modify options | Add VM options)?

If the issue persists, please also share a memory snapshot along with the latest log with all custom plugins disabled

https://intellij-support.jetbrains.com/hc/en-us/articles/207241235
0

Hello, I get exactly the same problem.

My tests:

  • simple unit : no issue
  • coverage, single method, no issue
  • coverage, single class, no issue
  • coverage, several selected failed classes : java.lang.OutOfMemoryError: Java heap space
  • Increase memory from 4Go to 8262 did not help. The tests failed too, but are a bit longer
  • Intellij version: 2025.2.4
  • Java version : 21.0.8+9-b1038.73 aarch64
  • OS : MacOS 26.0.1
0

Replacing the coverage runner from “IntelliJ IDEA” to “JaCoCo”, fixed the issue.

0

Hi Fabrice Daugan, thank you for your feedback.
Could you please set back the coverage runner to “IntelliJ IDEA” and after that perform the following steps:

  1. Reproduce the issue and capture a memory snapshot via Help | Diagnostic Tools | Capture Memory Snapshot when the problem occurs
  2. Collect IDE logs by performing Help | Collect Logs and Diagnostic Data

Please upload them to our server and provide us with the Upload ID. The uploaded data will be accessible only to our team and will be used solely for investigating this issue.
It will help us collect more information about the causes of the problem and internal errors.
Also, please make sure that all custom plugins are disabled to ensure the problem is platform-specific. Thanks!

0

Please sign in to leave a comment.