Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrating From HSQL DB 1.8 to 2.x memory issue

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

like image 868
Pinchy Avatar asked Jan 10 '14 03:01

Pinchy


2 Answers

If you only changed the HSQLDB version and it started giving memory problems, then it's a memory leak bug.

Upgrade to HSQLDB version 2.3.1, as there have been bug fixes after 2.0 concerning memory leaks, see the changelist since 2.0 here, one of the bug fixes says:

fixed issue causing reduced speed and memory leak with disk based result sets

Reduce memory consumption using HSQLDB:

Creating the tables using this syntax will reduce the memory consumption for sure, as like this tables exist on disk and only a part of them is loaded in memory:

CREATE CACHED TABLE YOUR_TABLE_NAME

Confirm that HSQLDB is the problem:

You can always memory profile the application to confirm the cause of the high memory consumption using Visual VM. This is a tool that is already installed together with the JDK, and can be launched via the command line with the command jvisualvm.

Check this 6 minutes tutorial video to see how it can help troubleshoot memory problems.

like image 148
Angular University Avatar answered Oct 19 '22 21:10

Angular University


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.

like image 2
fredt Avatar answered Oct 19 '22 19:10

fredt