java: OutOfMemoryError: insufficient memory while running JUnits in Idea

前端 未结 5 1624
一整个雨季
一整个雨季 2021-01-07 23:20

I am trying to run JUnits from my IntelliJ Idea When I try to run the Test.java file it gives me an error saying that

java: OutOfMemoryError: insuffic

5条回答
  •  星月不相逢
    2021-01-07 23:48

    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.

提交回复
热议问题