java: OutOfMemoryError: insufficient memory while running JUnits in Idea

Idea runs unit tests in a separate java process.

You need to use

Run -> Edit Configurations...

and add your -XmxNNNm to VM Options.

For example:

-ea -Xmx1024m

The "-ea" means "enable assertions".

If your unit test(s) can't run in a 1GB of memory then it's possible that you have a memory leak.


Based on your log the problem is in compiler heap space.

Go to

Settings -> Compiler -> Build process heap size (MB)

and increase that value.