Subject Re: [Firebird-Java] Spurious "unable to allocate memory from operating system" errors
Author Roman Rokytskyy
> When committing transactions with BLOBs in many threads, using Hibernate and Jaybird, I'm getting spurious memory exceptions from the Firebird driver.
>...
> Caused by: org.firebirdsql.jdbc.FBSQLException: I/O Exception. could not close blob: org.firebirdsql.gds.GDSException: unable to allocate memory from operating system

The reason is here - Firebird (not the driver) is not able to get memory
for some operation from the OS. It has nothing to do with the JDBC
driver, which simply reports the issue back to the application.

> 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.

Which is logical - Firebird won't be able to allocate more memory until
it is freed. So the task that consumed too much memory need to finish first.

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

I cannot think about any issue that is caused by the driver - the
execution path is pretty straightforward there - open blob, pump data
into it, close blob, put blob ID into SQLVAR, execute statement.

Maybe you can turn on SQL logging in Hibernate, so we can see what exact
statement is executed there? Maybe there is some operation performed on
the BLOB? Do you have any INSERT triggers there? How many rows are
inserted in one transaction?

Roman

PS I would keep discussing the issue in firebird-support, since it is
rather Firebird issue and more people with Firebird knowledge are
hanging there.