I am writing a simple Scala and Squeryl application. For testing purposes, every time I run 'test' in sbt, an H2 db database is created in memory and populated with test data. After each run, I see that the memory usage of java.exe (within which sbt works) in the task manager increases until after 4 or 5 starts it finishes with OutOfMemoryError. Am I missing something that explicitly frees up the memory used by H2 or Squeryl? Currently, I use only Session.create and then Persistence.create . Here is an excerpt from my code:
object Persistence extends Schema { val documents = table[IncomeEntity] val positions = table[Position] val documentToPositions = oneToManyRelation(documents, positions).via(_.id === _.id_income) } class PersistenceTests extends FunSuite with BeforeAndAfterAll { override protected def beforeAll() { Class.forName("org.h2.Driver") SessionFactory.concreteFactory = Some( () => Session.create(DriverManager.getConnection("jdbc:h2:mem:test"), new H2Adapter) ) } test("DDL") { transaction { Persistence.create assert(Persistence.documents.size == 0) assert(Persistence.positions.size == 0) } } test("Insert") { transaction { Persistence.create (1 to 100) map { _ => IncomeMapper.save(new Income) } assert(Persistence.documents.size == 100) } } }
The messages I receive are as follows:
[info] PersistenceTests: sbt appears to be exiting abnormally. The log file for this session is at C:\Users\Oleg\AppData\Local\Temp\sbt7320472784033855835.log java.lang.OutOfMemoryError: PermGen space Error during sbt execution: java.lang.OutOfMemoryError: PermGen space
source share