If you are fetching tens of thousands of rows for a list page, you may want to 
consider using the ERXBatchingDisplayGroup to minimize memory usage. By 
default, the WODisplayGroup pulls all the EOs into memory.  The batching 
display group uses the database to handle the pagination. It only creates the 
EO instances for the displayed batch.

If you're using a EODetailDataSource in the list page, the batching display 
group doesn't work AFAIK. In the case of large to-many relationships though, I 
would recommend you simply not model it as a relationship and handle it in 
code.  In that case, you'd probably want to place a limit on your fetch spec to 
prevent all the EOs being pulled into memory.  Big to-many relationships tend 
to cause issues when you addObjectToBothSides anyway.

Ramsey

On May 4, 2012, at 6:58 AM, Ron X wrote:

> i have small database - about 50 Mb...
> 
> code:
>         ListPageInterface listPage = D2W.factory().listPageForEntityNamed(
>                 Song.ENTITY_NAME, session());
>         EODataSource dataSource = new EODatabaseDataSource(session()
>                 .defaultEditingContext(), Song.ENTITY_NAME);
>         listPage.setDataSource(dataSource);
>         
>         return (WOComponent) listPage;
> 
> and error:
> 
>  N  19.07 MB used/104.87 MB free [WorkerThread8] 
> (ERXNSLogLog4jBridge.java:43)  - 
> <er.extensions.appserver.ERXComponentRequestHandler>: Exception occurred 
> while handling request:
> com.webobjects.foundation.NSForwardException [java.lang.OutOfMemoryError] 
> Java heap space:java.lang.OutOfMemoryError: Java heap space
> [2012-5-4 6:54:11 PDT] <WorkerThread8> 
> com.webobjects.foundation.NSForwardException [java.lang.OutOfMemoryError] 
> Java heap space:java.lang.OutOfMemoryError: Java heap space
>     at 
> com.webobjects.foundation.NSForwardException._runtimeExceptionForThrowable(NSForwardException.java:45)
>     at 
> com.webobjects.eocontrol.EOEditingContext.handleError(EOEditingContext.java:2971)
>     at 
> com.webobjects.eocontrol.EOEditingContext.objectsWithFetchSpecification(EOEditingContext.java:4071)
>     at er.extensions.eof.ERXEC.objectsWithFetchSpecification(ERXEC.java:1302)
>     at 
> com.webobjects.eoaccess.EODatabaseDataSource.fetchObjects(EODatabaseDataSource.java:589)
>     at com.webobjects.appserver.WODisplayGroup.fetch(WODisplayGroup.java:2132)
>     at er.extensions.appserver.ERXDisplayGroup.fetch(ERXDisplayGroup.java:135)
>     at 
> er.directtoweb.pages.ERD2WListPage._fetchDisplayGroup(ERD2WListPage.java:461)
>     at er.directtoweb.pages.ERD2WListPage.setupPhase(ERD2WListPage.java:561)
>     at 
> er.directtoweb.pages.ERD2WListPage.appendToResponse(ERD2WListPage.java:492)
>     at 
> com.webobjects.appserver.WOSession.appendToResponse(WOSession.java:1385)
>     at 
> er.extensions.appserver.ERXSession.appendToResponse(ERXSession.java:558)
>     at 
> com.webobjects.appserver.WOApplication.appendToResponse(WOApplication.java:1794)
>     at 
> er.extensions.appserver.ERXApplication.appendToResponse(ERXApplication.java:1994)
>     at 
> er.extensions.appserver.ERXComponentRequestHandler._dispatchWithPreparedPage(ERXComponentRequestHandler.java:190)
>     at 
> er.extensions.appserver.ERXComponentRequestHandler._dispatchWithPreparedSession(ERXComponentRequestHandler.java:235)
>     at 
> er.extensions.appserver.ERXComponentRequestHandler._dispatchWithPreparedApplication(ERXComponentRequestHandler.java:268)
>     at 
> er.extensions.appserver.ERXComponentRequestHandler._handleRequest(ERXComponentRequestHandler.java:302)
>     at 
> er.extensions.appserver.ERXComponentRequestHandler.handleRequest(ERXComponentRequestHandler.java:374)
>     at 
> com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:1687)
>     at 
> er.extensions.appserver.ERXApplication.dispatchRequestImmediately(ERXApplication.java:2098)
>     at 
> er.extensions.appserver.ERXApplication.dispatchRequest(ERXApplication.java:2063)
>     at 
> com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java:144)
>     at 
> com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:226)
>     at java.lang.Thread.run(Thread.java:680)
> Caused by: java.lang.OutOfMemoryError: Java heap space
>     at com.mysql.jdbc.MysqlIO.nextRowFast(MysqlIO.java:2145)
>     at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1922)
>     at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:3425)
>     at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:481)
>     at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:3120)
>     at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:2288)
>     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2709)
>     at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2671)
>     at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2621)
>     at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:842)
>     at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:681)
>     at 
> com.webobjects.jdbcadaptor.JDBCChannel._bindInputVariablesWithBindingsAndExecute(JDBCChannel.java:272)
>     at 
> com.webobjects.jdbcadaptor.JDBCChannel._evaluateExpression(JDBCChannel.java:337)
>     at 
> com.webobjects.jdbcadaptor.JDBCChannel.evaluateExpression(JDBCChannel.java:296)
>     at 
> com.webobjects.jdbcadaptor.JDBCChannel.selectAttributes(JDBCChannel.java:220)
>     at 
> com.webobjects.eoaccess.EODatabaseChannel._selectWithFetchSpecificationEditingContext(EODatabaseChannel.java:897)
>     at 
> com.webobjects.eoaccess.EODatabaseChannel.selectObjectsWithFetchSpecification(EODatabaseChannel.java:234)
>     at 
> com.webobjects.eoaccess.EODatabaseContext._objectsWithFetchSpecificationEditingContext(EODatabaseContext.java:3055)
>     at 
> er.extensions.eof.ERXDatabaseContext._objectsWithFetchSpecificationEditingContext(ERXDatabaseContext.java:66)
>     at 
> com.webobjects.eoaccess.EODatabaseContext.objectsWithFetchSpecification(EODatabaseContext.java:3195)
>     at 
> com.webobjects.eocontrol.EOObjectStoreCoordinator.objectsWithFetchSpecification(EOObjectStoreCoordinator.java:488)
>     at 
> com.webobjects.eocontrol.EOEditingContext.objectsWithFetchSpecification(EOEditingContext.java:4069)
>     at er.extensions.eof.ERXEC.objectsWithFetchSpecification(ERXEC.java:1302)
>     at 
> com.webobjects.eoaccess.EODatabaseDataSource.fetchObjects(EODatabaseDataSource.java:589)
>     at com.webobjects.appserver.WODisplayGroup.fetch(WODisplayGroup.java:2132)
>     at er.extensions.appserver.ERXDisplayGroup.fetch(ERXDisplayGroup.java:135)
>     at 
> er.directtoweb.pages.ERD2WListPage._fetchDisplayGroup(ERD2WListPage.java:461)
>     at er.directtoweb.pages.ERD2WListPage.setupPhase(ERD2WListPage.java:561)
>     at 
> er.directtoweb.pages.ERD2WListPage.appendToResponse(ERD2WListPage.java:492)
>     at 
> com.webobjects.appserver.WOSession.appendToResponse(WOSession.java:1385)
>     at 
> er.extensions.appserver.ERXSession.appendToResponse(ERXSession.java:558)
>     at 
> com.webobjects.appserver.WOApplication.appendToResponse(WOApplication.java:1794)
> 
> WARN  19.07 MB used/104.87 MB free [WorkerThread8] 
> (ERXNSLogLog4jBridge.java:43)  - Ran out of memory, killing this instance
> FATAL 19.33 MB used/104.61 MB free [WorkerThread8] (ERXApplication.java:1935) 
>  - Ran out of memory, killing this instance
> FATAL 19.33 MB used/104.61 MB free [WorkerThread8] (ERXApplication.java:1936) 
>  - Ran out of memory, killing this instance
> OutOfMemoryError: Java heap space
>   at com.mysql.jdbc.MysqlIO.nextRowFast(MysqlIO.java:2145)
>   at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1922)
>   at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:3425)
>   at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:481)
>   at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:3120)
>   at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:2288)
>   at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2709)
>   at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2671)
>   at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2621)
>   at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:842)
>   at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:681)
>      ... skipped 7 stack elements
>   at 
> er.extensions.eof.ERXDatabaseContext._objectsWithFetchSpecificationEditingContext(ERXDatabaseContext.java:66)
>      ... skipped 1 stack elements
>   at 
> com.webobjects.eocontrol.EOObjectStoreCoordinator.objectsWithFetchSpecification(EOObjectStoreCoordinator.java:488)
>   at 
> com.webobjects.eocontrol.EOEditingContext.objectsWithFetchSpecification(EOEditingContext.java:4069)
>   at er.extensions.eof.ERXEC.objectsWithFetchSpecification(ERXEC.java:1302)
>      ... skipped 1 stack elements
>   at com.webobjects.appserver.WODisplayGroup.fetch(WODisplayGroup.java:2132)
>   at er.extensions.appserver.ERXDisplayGroup.fetch(ERXDisplayGroup.java:135)
>   at 
> er.directtoweb.pages.ERD2WListPage._fetchDisplayGroup(ERD2WListPage.java:461)
>   at er.directtoweb.pages.ERD2WListPage.setupPhase(ERD2WListPage.java:561)
>   ... skipped 4 stack elements
> Exception in thread "Poller SunPKCS11-Darwin" java.lang.OutOfMemoryError: 
> Java heap space
>     at sun.security.pkcs11.wrapper.PKCS11.C_GetSlotInfo(Native Method)
>     at sun.security.pkcs11.SunPKCS11.initToken(SunPKCS11.java:767)
>     at sun.security.pkcs11.SunPKCS11.access$100(SunPKCS11.java:42)
>     at sun.security.pkcs11.SunPKCS11$TokenPoller.run(SunPKCS11.java:700)
>     at java.lang.Thread.run(Thread.java:680)
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      ([email protected])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/rgurley%40smarthealth.com
> 
> This email sent to [email protected]


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to