JVM memory settings for specs2
Asked Answered
T

2

7

SBT keeps running out of memory on some of my bigger acceptance style tests using specs2 and spray-testkit. I have 10 gigs or RAM available and currently I start SBT (using the SBT extras script) with MaxPermSize at 512m, Xms at 1024m and Xmx at 2g.

The acceptance test runs through a client's entire business process in specific sequence, so it's not easy to split the acceptance test in to multiple smaller tests.

Any ideas how I can configure my environment better, or gotcha's that I should look out for will be appreciated.

For what it's worth, I'm using Oracle Java under Ubuntu, and the project uses Scala 2.10, sbt 0.12.2, spray 1.1-M7 with specs2 1.14.

When running the system outside of test, or when using smaller tests, everything runs like clockwork. It's only during larger tests that things go nutty.

Toughminded answered 20/3, 2013 at 10:22 Comment(0)
M
2

I suspect you're hitting the exponential problem with the specs2 immutable style. The solution is simply to add more memory or bust your tests up into smaller chunks. More info is here:

http://www.artima.com/articles/compile_time.html

Manservant answered 20/3, 2013 at 23:20 Comment(0)
F
7

One thing you can do is to fork your tests, you can set your memory settings in the build.sbt directly:

fork in Test := true

javaOptions in Test += "-Xmx2048m" // we need lots of heap space

This means that the tests don't depend on you running with the SBT extras script, and the settings don't affect sbt itself. You can also set various other options (see Forking), including changing the working directory, and even the JRE to use.

Fatalism answered 20/3, 2013 at 12:13 Comment(2)
closely related to #3869363Shipowner
took me a minute to realize you need a line between those two.Berglund
M
2

I suspect you're hitting the exponential problem with the specs2 immutable style. The solution is simply to add more memory or bust your tests up into smaller chunks. More info is here:

http://www.artima.com/articles/compile_time.html

Manservant answered 20/3, 2013 at 23:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.