javafirebirddbeaverjaybird

Querying Firebird database results in Java Heap Space error


I'm having some trouble with Firebird. Some SQL queries are getting the error "Java Heap Space".

I've revised all queries and seems to be right. But, after doing some tests, I've noted that the error only occurs when SQL query has no limits of returned rows. If i run the query using SELECT FIRST(10) field1, field2 from table, it returns the result from db, without FIRST(), the error occurs.

The original server where Firebird was installed has limited memory, so I just installed Firebird on my personal computer, restored the backup and tested it. My current computer has a lot of ram and CPU to run this simple query and The same problem occurs.

My Firebird version is 2.5. I've searched in Firebird official documentation, but haven't found anything helpful. Anyone knows what could be causing this error?

Below is the print of error and my computer task manager during the tests.

FireBird Java Heap Space Eror

[TaskManager2]


Solution

  • This problem has nothing to do with the memory usage of Firebird server itself. Your query tool is a Java application (it looks like DBeaver, but could also be a different Eclipse-based application), and retrieving all rows consumes too much memory. When Java can not allocate sufficient memory, this results in a OutOfMemoryError with message "Java heap space"

    You either need to configure that application to use more memory, or find out if it can retrieve rows in pages instead of fetching all. Jaybird (the Firebird JDBC driver) itself will retrieve all rows when the query is executed in auto-commit mode, so maybe you will need to execute it in a transaction.

    Alternatively, as you already found out: don't query all rows.