Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JVM memory settings for specs2

Tags:

sbt

spray

specs2

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.

like image 304
Jack Avatar asked Mar 20 '13 10:03

Jack


2 Answers

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.

like image 150
Matthew Farwell Avatar answered Nov 03 '22 02:11

Matthew Farwell


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

like image 40
Bill Venners Avatar answered Nov 03 '22 00:11

Bill Venners