java - Could not reserve enough space for object heap when running JUnit tests -
in project have unit tests. using intellij. whenever seek run them, intellij shows message:
error occured during initialization of vm
could not reserve plenty space object heap
could not create java virtual machine.
i tried run tests vm arguments run configuration -> vm options: -xms256m -xmx512m
have read lot problem (and proposed solutions), tried many combinations, none of them worked. became frustrated , thought test "too complicated" (mocks , things that...), have written sample test:
public class testclass { @test public void test() { asserttrue(true); } }
i still getting same error! problem occurs only when running tests - other methods run fine. ideas may cause unusual , annoying error? new intellij, maybe missing something.
update
i tried run tests command line, same result. able run them, adding -dforkmode=never
maven command. still not able run test(s) intellij.
i faced same issue resolved me. if using maven, can configure default jvm args or other test options need passed runs adding similar properties pom.xml
. might want note kind of master setting junit runs.
<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-surefire-plugin</artifactid> <version>2.8.1</version> <configuration> <argline>-xms500m -xmx1g</argline> <enableassertions>true</enableassertions> <testfailureignore>true</testfailureignore> </configuration> </plugin>
in case, project had configuration set utilize -xms10g -xmx10g
. replacing lower values -xms500m -xmx1g
fixed issue.
you might have similar configuration may want override locally, else adding configuration should help override default values passed intellij.
java intellij-idea junit
No comments:
Post a Comment