Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PostgreSQL的Java内存不足_Java_Postgresql_Memory - Fatal编程技术网

使用PostgreSQL的Java内存不足

使用PostgreSQL的Java内存不足,java,postgresql,memory,Java,Postgresql,Memory,还有一个可能与此相关的问题,但没有答案,询问者也没有澄清任何问题 所以当我在postgres中查看一个大的结果集时,java似乎崩溃了 我正在运行的查询试图获得大约550万行。基本上,我试图从Postgres数据库填充Neo4J数据库 除非有人问我,否则我不会发布代码,因为我认为这是非常通用的。以下是异常输出: Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.lang.Class

还有一个可能与此相关的问题,但没有答案,询问者也没有澄清任何问题

所以当我在postgres中查看一个大的结果集时,java似乎崩溃了

我正在运行的查询试图获得大约550万行。基本上,我试图从Postgres数据库填充Neo4J数据库

除非有人问我,否则我不会发布代码,因为我认为这是非常通用的。以下是异常输出:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Unknown Source)
    at java.lang.Class.getDeclaredField(Unknown Source)
    at java.util.concurrent.atomic.AtomicReferenceFieldUpdater$AtomicReferenceFieldUpdaterImpl.<init>(Unknown Source)
    at java.util.concurrent.atomic.AtomicReferenceFieldUpdater.newUpdater(Unknown Source)
    at java.sql.SQLException.<clinit>(Unknown Source)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1818)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:374)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:254)
    at sqlToGraph.SqlToGraph.main(SqlToGraph.java:52)
所以我想rs的规模越来越大了。我想我可以使用LIMIT和OFFSET来运行程序几百次,或者让它在一个循环中重置rs,但我宁愿不这样做

  • 将提取大小设置为合理的值(
    st.setFetchSize(rowCount)
    )。你可以试试这个
  • 在自动提交关闭的情况下将所有内容放入事务中(
    con.setAutoCommit(false)

  • 请参阅和。

    谢谢,这完全解决了问题。直到Neo4J耗尽内存。哦,还有更多的问题要问。。。
    rs = st.executeQuery("select player_lo, player_hi, total_hands_lo, total_hands_hi, (pc_lo + pc_hi)/2 as avg_pc from pair");