Subject Spurious "unable to allocate memory from operating system" errors
Author Wendel Schaatsbergen
Note: reposted from the firebird-support list.

Hi all,

Problem synopsis:

When committing transactions with BLOBs in many threads, using Hibernate and Jaybird, I'm getting spurious memory exceptions from the Firebird driver.

My setup:

I have a web application that runs with the following installation:
- Windows 7
- Firebird 2.5 Super Server
- JDK 1.6.0
- Jaybird 2.1.6
- Hibernate 3.5.6
- Tomcat 6.0

I'm using the standard firebird.conf file of the super server installation.

Problem details:

I have a daemon task which at certain times spawns many tasks that load a BLOB, does calculations on it, and stores the result either in a new row in another table, or it saves back a changed version of the original BLOB. The tasks correctly commit the transactions and close the hibernate session.

After some time of correctly committing the transactions, the tasks start to give the following exception:

org.hibernate.exception.GenericJDBCException: could not execute query using scroll
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(
at org.hibernate.exception.SQLStateConverter.convert(
at org.hibernate.exception.JDBCExceptionHelper.convert(
at org.hibernate.loader.Loader.scroll(
at org.hibernate.loader.hql.QueryLoader.scroll(
at org.hibernate.hql.ast.QueryTranslatorImpl.scroll(
at org.hibernate.engine.query.HQLQueryPlan.performScroll(
at org.hibernate.impl.SessionImpl.scroll(
at org.hibernate.impl.QueryImpl.scroll(
at org.hibernate.impl.QueryImpl.scroll(
at ch.gutermann.zonescan.server.correlation.NSquareCorrelationJob.startMonthlyAveragingTasks(Unknown Source)
at ch.gutermann.zonescan.server.correlation.NSquareCorrelationJob.startCorrelations(Unknown Source)
at ch.gutermann.zonescan.server.correlation.NSquareCorrelationJob.execute(Unknown Source)
at org.quartz.simpl.SimpleThreadPool$
Caused by: org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544676. sort error: not enough memory
at org.firebirdsql.jdbc.AbstractPreparedStatement.internalExecute(
at org.firebirdsql.jdbc.AbstractPreparedStatement.executeQuery(
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(
at org.hibernate.jdbc.AbstractBatcher.getResultSet(
at org.hibernate.loader.Loader.getResultSet(
at org.hibernate.loader.Loader.scroll(
... 11 more

When this happens, every subsequent task will give the same error, "unable to allocate memory from operating system". However, when I wait several minutes and then start the tasks again, the tasks will run correctly again for some time, potentially starting to give the error again later on.

Has anybody had similar problems involving multithreaded transaction with many BLOBs? Is there anything I could do to fix or work around this problem?

Thanks for any help!

Wendel Schaatsbergen