Migrating From HSQL DB 1.8 to 2.x memory issue

hibernate, hsqldb, integration-testing

Solution

Currently there is no memory leak in HSQLDB. As you are using a memory database, you need to get rid of the data you inserted into the database during tests. It seems the data is not released in your app.

The simplest way to ensure all the tables and their data in a schema is released is this:

DROP SCHEMA schemaname CASCADE

or alternatively SHUTDOWN the database after a series of tests:

SHUTDOWN

Execute the above statements with your schema name after some tests have finished to release all the data.

The main thing that has changed from version 1.8.0 is support for transactions. Hibernate treats the new versions differently. Therefore you need to check if some connection remains open or not, so SHUTDOWN is performed when the last connection is closed.

Problem

I have recently migrated HQLDB from 1.8 to 2.x and after that my integration (in memory) test has started using too much memory. Increasing memory to 6GB makes the test go faster but still at some point manages to freeze. I have the properties shutdown=true; on url parameters adding hsqldb.write_delay=false won't make any difference. Before the upgrade it was working without any problems. I cannot find any hints in the migration guide http://hsqldb.org/web/hsqlFAQ.html

Original source