[Hibernate-JIRA] Created: (HHH-3495) CollectionAction instances can consume considerable memory in large transactions unnecessarily
by Tim Downey (JIRA)
CollectionAction instances can consume considerable memory in large transactions unnecessarily
----------------------------------------------------------------------------------------------
Key: HHH-3495
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3495
Project: Hibernate Core
Issue Type: Improvement
Reporter: Tim Downey
Attachments: CollectionActionPatch.zip
Hi,
We're doing some fairly heavy duty batch processing using Hibernate 3.3.1. In doing so, we're basically paging over large chunks of entities where we flush and clear the session around pages. We do not commit between pages. We may be processing hundreds of thousands of entities over pages of ten to twenty thousand each.
We're clearing the session around pages in attempt to free up memory that is no longer necessary. We have found that subtypes of CollectionAction get added to a list of Executable in the ActionQueue when there are collection changes processed. These CollectionActions are held until transaction complete and are not released on flush or clear of the session.
Furthermore, the CollectionAction instances hold references to those collections that have changed even after the entities have been evicted from the session. In our case, this was causing Hibernation to hold on to several hundred MB of RAM until transaction commit.
I've supplied a small patch that doesn't require the CollectionAction to hang on to the entities themselves until the transaction boundary. We're showing considerably improvement in memory utilization as a result. I'm hoping that you consider this patch for inclusion in a future release.
The change was basically to change the ActionQueue's list of Executables used in after transaction completion, to a separate type, AfterTransactionCompletionExecutable. This new type allows some decoupling in the other subclasses of Executable to hold references to fewer resources and save considerable memory when the transaction sizes are quite large.
Regards,
Tim
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years
[Hibernate-JIRA] Created: (HHH-2169) L2 Cache and Long transactions Memory Leak : OutOfMemoryException
by Sami Dalouche (JIRA)
L2 Cache and Long transactions Memory Leak : OutOfMemoryException
-----------------------------------------------------------------
Key: HHH-2169
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2169
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.0.ga
Environment: [b]Hibernate version:[/b]
Hibernate Entity Manager 3.2.0, with Hibernate Core 3.2.0 and Hibernate Annotations 3.2.0
[b]Mapping documents:[/b]
Annotations
[b]Full stack trace of any exception that occurs:[/b]
Memory Heap Exception
[b]Name and version of the database you are using:[/b]
PosgreSQL 8.1
Reporter: Sami Dalouche
Summary
---------
When enabling L2 Cache (with either OScache and EhCache, both with a limitation on the max #of instances, so the problem shouldn't come from the cache manager), Hibernate cannot have long running transactions, otherwise, it results in a Memory Heap Exception...
The problem does NOT happen if the L2 Cache is disabled !
Details
----------
- Configure the code to run in ONE transaction
- Have a huge loop that inserts 2 million entries that are cacheable (@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE))
- flush() and clear() every 1000 entries, to periodically flush the cache
=> None of the entries are garbage collected.
=> Using a profiler, it is possible to trace the owning objects of my domain classes to :
- org.hibernate.action.EntityInsertAction ("instance" variable)
- array / List (variable elementData)
- variable "executions" in object .. class org.hibernate.engine.ActionQueue
Remarks :
- If the Query Cache is disabled, and the objects being inserted are NOT cacheable (no @Cache annotation), there is no problem
- If the Query Cache is enabled, then, no matter whether the objects being inserted are cacheable or not, The entries are never garbage collected, and I get an OutOfMemoryException. (I see NO relationship between the Query Cache and my objects. I never query the objects, only save them !!)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
13 years
[Hibernate-JIRA] Created: (HHH-6329) Apparently inaccurate 'java.lang.UnsupportedOperationException: Illegal attempt to edit read only item' when using SQLQuery.executeUpdate
by Alex Hayward (JIRA)
Apparently inaccurate 'java.lang.UnsupportedOperationException: Illegal attempt to edit read only item' when using SQLQuery.executeUpdate
-----------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-6329
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6329
Project: Hibernate Core
Issue Type: Bug
Components: caching (L2), core
Affects Versions: 3.6.5
Environment: Hibernate 3.6.5, PostgreSQL, OpenJDK 7.0.144, FreeBSD 8.2
Reporter: Alex Hayward
The following code (and, indeed, anything similar using INSERT):
SQLQuery createSequence = sess.createSQLQuery("CREATE SEQUENCE printOrder" + getId());
createSequence.executeUpdate();
results in an attempt to flush the entire L2 cache. This, in turn, results in:
java.lang.UnsupportedOperationException: Illegal attempt to edit read only item
at org.hibernate.cache.infinispan.entity.ReadOnlyAccess.lockRegion(ReadOnlyAccess.java:28)
at org.hibernate.action.BulkOperationCleanupAction$EntityCleanup.<init>(BulkOperationCleanupAction.java:205)
at org.hibernate.action.BulkOperationCleanupAction$EntityCleanup.<init>(BulkOperationCleanupAction.java:199)
at org.hibernate.action.BulkOperationCleanupAction.<init>(BulkOperationCleanupAction.java:120)
at org.hibernate.engine.query.NativeSQLQueryPlan.coordinateSharedCacheCleanup(NativeSQLQueryPlan.java:176)
at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:189)
at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1310)
at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:396)
at BoxOffice.BusinessObjects.PrintQueue.createPrintOrderSequence(PrintQueue.java:77)
at BoxOffice.Server.CorbaImpl.PrintManager.addPrintQueue(PrintManager.java:808)
at BoxOffice.Server.CorbaImpl.PrintManagerImpl.addPrintQueue(PrintManagerImpl.java:938)
at BoxOffice.CORBA.PrintManagerPOATie.addPrintQueue(PrintManagerPOATie.java:78)
at BoxOffice.CORBA.PrintManagerPOA._invoke(PrintManagerPOA.java:198)
at org.jacorb.poa.RequestProcessor.invokeOperation(RequestProcessor.java:301)
at org.jacorb.poa.RequestProcessor.process(RequestProcessor.java:604)
at org.jacorb.poa.RequestProcessor.run(RequestProcessor.java:747)
'persister' on line 120 of BulkOperationCleanupAction is 'SingleTableEntityPersister(BoxOffice.BusinessObjects.Country)' when this happens. 'Country' is a read-only object. None have been modified. Using doWork instead works, but is unfortunately a rather awkward API for many cases.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years