简体   繁体   English

查询 Firebird 数据库导致 Java 堆空间错误

[英]Querying Firebird database results in Java Heap Space error

I'm having some trouble with Firebird.我在使用 Firebird 时遇到了一些麻烦。 Some SQL queries are getting the error "Java Heap Space".一些 SQL 查询收到错误“Java 堆空间”。

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.但是,在做了一些测试之后,我注意到只有当 SQL 查询没有返回行数限制时才会发生错误。 If i run the query using SELECT FIRST(10) field1, field2 from table , it returns the result from db, without FIRST() , the error occurs.如果我使用SELECT FIRST(10) field1, field2 from table运行查询,它会从 db 返回结果,没有FIRST() ,就会发生错误。

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.原来安装 Firebird 的服务器内存有限,所以我只是在我的个人电脑上安装了 Firebird,恢复了备份并测试了它。 My current computer has a lot of ram and CPU to run this simple query and The same problem occurs.我当前的计算机有很多内存和 CPU 来运行这个简单的查询,并且发生了同样的问题。

My Firebird version is 2.5.我的 Firebird 版本是 2.5。 I've searched in Firebird official documentation, but haven't found anything helpful.我在 Firebird 官方文档中搜索过,但没有找到任何有用的信息。 Anyone knows what could be causing this error?任何人都知道可能导致此错误的原因是什么?

Below is the print of error and my computer task manager during the tests.以下是测试期间的错误打印和我的计算机任务管理器。

FireBird Java 堆空间错误

[ [任务管理器2]

This problem has nothing to do with the memory usage of Firebird server itself.此问题与 Firebird 服务器本身的内存使用无关。 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.您的查询工具是一个 Java 应用程序(它看起来像 DBeaver,但也可能是一个不同的基于 Eclipse 的应用程序),检索所有行会消耗太多内存。 When Java can not allocate sufficient memory, this results in a OutOfMemoryError with message "Java heap space"当 Java 无法分配足够的内存时,这会导致OutOfMemoryError并带有消息“Java 堆空间”

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.在自动提交模式下执行查询时,Jaybird(Firebird JDBC 驱动程序)本身将检索所有行,因此您可能需要在事务中执行它。

Alternatively, as you already found out: don't query all rows.或者,正如您已经发现的:不要查询所有行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM