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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With