OutOfMemoryError: Trying to optimise Maven multi-module unit tests using HSQLDB, DBUnit, unitils, Hibernate, Spring -


i have big multi-module maven project thousands of tests. each test loads daos, services, etc using springapplicationcontext annotation. unitils configuration looks this:

database.driverclassname=org.hsqldb.jdbcdriver database.url=jdbc:hsqldb:file:mytestdb database.schemanames=public database.username=sa database.password= database.dialect=hsqldb unitils.modules=database,dbunit,hibernate,inject,spring # custom version of hsqldbdbsupport calls "set referential_integrity false" org.unitils.core.dbsupport.dbsupport.implclassname.hsqldb=my.company.unitils.hsqldbdbsupport org.dbunit.dataset.datatype.idatatypefactory.implclassname.hsqldb=org.dbunit.ext.hsqldb.hsqldbdatatypefactory org.unitils.dbmaintainer.structure.constraintsdisabler.implclassname=org.unitils.dbmaintainer.structure.impl.defaultconstraintsdisabler # custom version of cleaninsertloadstrategy calls "databaseunitils.disableconstraints();" dbunitmodule.dataset.loadstrategy.default=my.company.unitils.datasetloadstrategy hibernatemodule.configuration.implclassname=org.hibernate.cfg.annotationconfiguration dbmaintainer.disableconstraints.enabled=true dbmaintainer.cleandb.enabled=true dbmaintainer.generatedatasetstructure.enabled=false datasetstructuregenerator.xsd.dirname=target/xsd dbmaintainer.autocreateexecutedscriptstable=true updatedatabaseschema.enabled=false dbmaintainer.fromscratchenabled=true 

my hibernate configuration looks this:

hibernate.hbm2ddl.auto=update hibernate.show_sql=false hibernate.format_sql=false hibernate.dialect=org.hibernate.dialect.hsqldialect hibernate.connection.autocommit=false hibernate.cache.provider_class=org.hibernate.cache.nocacheprovider hibernate.cache.use_query_cache=false hibernate.cache.use_second_level_cache=false hibernate.cache.use_structured_entries=false hibernate.generate_statistics=false 

when run tests, 2gb allocated heap fills up. permgen reaches 400mb. looking @ heap dump, char, java.lang.string , java.lang.string[] takes 40% of total instances.

when spot-check few of these instances, gc root traces to:

  • the spring context manager (in form of context xml extracts)
  • the sessionfactory (in form of queries)

i optimise these 2 things, , think respectively caused by:

  • each test has @springapplicationcontext annotation
  • each test uses unitils @dataset annotation load data test.

note, use jdbc:hsqldb:file offload data off of heap (i.e. instead of using jdbc:hsqldb:mem)

versions:
hsqldb 1.8.0.7
spring 3.0.4.release
unitils 3.1

ps can 1500+ rating please tag question "unitils"?

if memory taken data stored in database, can make database use disk based tables reduce memory use. can specified on database url:

database.url=jdbc:hsqldb:file:mytestdb;hsqldb.default_table_type=cached


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -