Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 6994463480C for ; Tue, 22 Dec 2009 00:15:44 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 37554-06-3 for ; Tue, 22 Dec 2009 04:15:37 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from xebia-exchange.hosted.xebia.com (xebia-exchange.hosted.xebia.com [85.158.206.36]) by mail.postgresql.org (Postfix) with ESMTP id E778C63467A for ; Tue, 22 Dec 2009 00:15:33 -0400 (AST) Received: from [127.0.0.1] ([61.16.153.138]) by xebia-exchange.hosted.xebia.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 22 Dec 2009 05:07:50 +0100 Message-ID: <4B3047E7.9020901@xebia.com> Date: Tue, 22 Dec 2009 09:45:35 +0530 From: Ankit Kumar User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: OutOfMemory hibernate scroll with 2M records | Postgresql 8.4 DB Content-Type: multipart/alternative; boundary="------------030209050305020703040207" X-OriginalArrivalTime: 22 Dec 2009 04:07:50.0953 (UTC) FILETIME=[5413D990:01CA82BC] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.851 tagged_above=-10 required=5 tests=BAYES_05=-1.11, HTML_MESSAGE=0.001, RCVD_IN_BL_SPAMCOP_NET=1.96 X-Spam-Level: X-Archive-Number: 200912/83 X-Sequence-Number: 20164 This is a multi-part message in MIME format. --------------030209050305020703040207 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi I am running a Criteria.scroll() on postgresql on a DB containing 2M records. The memory keeps increasing and finally it generates an OutOfMemoryException. Please can you advice how to fix this. *Postgresql DB version:* 8.4 *Postgresql Driver Used:* postgresql-8.4-701.jdbc4.jar Some forums do mention that "/scroll/" is slow on Postgresql. Is this a known issue or we need to do something specific to make scroll work on Postgresql? It appears the driver class is loading all entity objects in memory and not releasing them as expected in a scroll operation. Appreciate any guidance/suggestion. *Exception StackTrace*: java.lang.OutOfMemoryError: Java heap space at java.lang.Class.getDeclaredFields0(Native Method) at java.lang.Class.privateGetDeclaredFields(Class.java:2291) at java.lang.Class.getDeclaredField(Class.java:1880) at java.util.concurrent.atomic.AtomicReferenceFieldUpdater$AtomicReferenceFieldUpdaterImpl.(AtomicReferenceFieldUpdater.java:181) at java.util.concurrent.atomic.AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdater.java:65) at java.sql.SQLException.(SQLException.java:353) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1777) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186) at org.hibernate.loader.Loader.getResultSet(Loader.java:1787) at org.hibernate.loader.Loader.scroll(Loader.java:2286) at org.hibernate.loader.criteria.CriteriaLoader.scroll(CriteriaLoader.java:89) at org.hibernate.impl.SessionImpl.scroll(SessionImpl.java:1533) at org.hibernate.impl.CriteriaImpl.scroll(CriteriaImpl.java:297) at org.hibernate.impl.CriteriaImpl.scroll(CriteriaImpl.java:291) at com.hi.openname.dao.impl.HibernateKnowledgeItemDao.loadAllCommitted(HibernateKnowledgeItemDao.java:104) at com.hi.openname.dao.impl.HibernateKnowledgeItemDao.loadAllCommitted(HibernateKnowledgeItemDao.java:1) Regards Ankit --------------030209050305020703040207 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi

I am running a Criteria.scroll() on postgresql on a DB containing 2M records. The memory keeps increasing and finally it generates an OutOfMemoryException. Please can you advice how to fix this.

Postgresql DB version: 8.4
Postgresql Driver Used: postgresql-8.4-701.jdbc4.jar

Some forums do mention that "scroll" is slow on Postgresql.

Is this a known issue or we need to do something specific to make scroll work on Postgresql?

It appears the driver class is loading all entity objects in memory and not releasing them as expected in a scroll operation.


Appreciate any guidance/suggestion.

Exception StackTrace:
java.lang.OutOfMemoryError: Java heap space
 at java.lang.Class.getDeclaredFields0(Native Method)
 at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
 at java.lang.Class.getDeclaredField(Class.java:1880)
 at java.util.concurrent.atomic.AtomicReferenceFieldUpdater$AtomicReferenceFieldUpdaterImpl.<init>(AtomicReferenceFieldUpdater.java:181)
 at java.util.concurrent.atomic.AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdater.java:65)
 at java.sql.SQLException.<clinit>(SQLException.java:353)
 at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1777)
 at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
 at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
 at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
 at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
 at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
 at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
 at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
 at org.hibernate.loader.Loader.scroll(Loader.java:2286)
 at org.hibernate.loader.criteria.CriteriaLoader.scroll(CriteriaLoader.java:89)
 at org.hibernate.impl.SessionImpl.scroll(SessionImpl.java:1533)
 at org.hibernate.impl.CriteriaImpl.scroll(CriteriaImpl.java:297)
 at org.hibernate.impl.CriteriaImpl.scroll(CriteriaImpl.java:291)
 at com.hi.openname.dao.impl.HibernateKnowledgeItemDao.loadAllCommitted(HibernateKnowledgeItemDao.java:104)
 at com.hi.openname.dao.impl.HibernateKnowledgeItemDao.loadAllCommitted(HibernateKnowledgeItemDao.java:1)

Regards
Ankit


--------------030209050305020703040207--