Subject | Spurious "unable to allocate memory from operating system" errors |
---|---|
Author | lazyf0x |
Post date | 2011-05-19T11:18:46Z |
Hi,
I'm having a strange memory problem when committing transactions with BLOBs in many threads, using Hibernate and Jaybird on Java with Firebird. Here's my setup:
- Firebird 2.5
- JDK 1.6.0
- Jaybird 2.1.6
- Hibernate 3.5.6
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 insert: [ch.gutermann.zonescan.model.SummedMeasurement]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2438)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2858)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:267)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:259)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:178)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at ch.gutermann.zonescan.server.correlation.MeasAveragingTask.run(MeasAveragingTask.java:155)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.firebirdsql.jdbc.FBSQLException: I/O Exception. could not close blob: org.firebirdsql.gds.GDSException: unable to allocate memory from operating system
at org.firebirdsql.jdbc.FBBlob.copyBytes(FBBlob.java:516)
at org.firebirdsql.jdbc.field.FBBlobField.copyBytes(FBBlobField.java:265)
at org.firebirdsql.jdbc.field.FBBlobField.flushCachedData(FBBlobField.java:239)
at org.firebirdsql.jdbc.AbstractPreparedStatement.flushFields(AbstractPreparedStatement.java:749)
at org.firebirdsql.jdbc.AbstractPreparedStatement.internalExecute(AbstractPreparedStatement.java:723)
at org.firebirdsql.jdbc.AbstractPreparedStatement.executeUpdate(AbstractPreparedStatement.java:190)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:46)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2418)
... 14 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.
This sounds to me like some kind of buffer is being overflowed. But what kind of buffer is it, and how can I avoid this from happening?
Thanks for any help!
Bye,
Wendel Schaatsbergen
I'm having a strange memory problem when committing transactions with BLOBs in many threads, using Hibernate and Jaybird on Java with Firebird. Here's my setup:
- Firebird 2.5
- JDK 1.6.0
- Jaybird 2.1.6
- Hibernate 3.5.6
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 insert: [ch.gutermann.zonescan.model.SummedMeasurement]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2438)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2858)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:267)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:259)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:178)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at ch.gutermann.zonescan.server.correlation.MeasAveragingTask.run(MeasAveragingTask.java:155)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.firebirdsql.jdbc.FBSQLException: I/O Exception. could not close blob: org.firebirdsql.gds.GDSException: unable to allocate memory from operating system
at org.firebirdsql.jdbc.FBBlob.copyBytes(FBBlob.java:516)
at org.firebirdsql.jdbc.field.FBBlobField.copyBytes(FBBlobField.java:265)
at org.firebirdsql.jdbc.field.FBBlobField.flushCachedData(FBBlobField.java:239)
at org.firebirdsql.jdbc.AbstractPreparedStatement.flushFields(AbstractPreparedStatement.java:749)
at org.firebirdsql.jdbc.AbstractPreparedStatement.internalExecute(AbstractPreparedStatement.java:723)
at org.firebirdsql.jdbc.AbstractPreparedStatement.executeUpdate(AbstractPreparedStatement.java:190)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:46)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2418)
... 14 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.
This sounds to me like some kind of buffer is being overflowed. But what kind of buffer is it, and how can I avoid this from happening?
Thanks for any help!
Bye,
Wendel Schaatsbergen