[hibernate-dev] Memory consumption
After executing actions, the actions (e.g. EntityInsertAction) will be moved from ActionQueue.inserts etc. to ActionQueue.executions to stay there until the transaction completes. Because they do have a reference to the instance being saved, they prevent that instance from being garbage collected. Isn't it possible to clear the instance field after execution? For example the EntityInsertAction needs the entity just for getting the id. Can't the id be retrieved direcly after execution? I ask, because I tried to insert many new objects to the database and tried with Session.flush() and Session.evict() to get rid of these objects each 1000 objects, because the memory usage was too high. But for the above reason I had no chance to succeed. The workaround was to commit the session more often, but this breaks transactional behaviour. Any thoughts? Markus Heiden ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
Re: [hibernate-dev] Memory consumption
Hi Darryl, the problem is the memory consumption. The database has no problems with the size of the transaction (I tested this by increasing the max heap size to 1 GB). The workaround I use works for now, so that I need no complex solution for first. My intend was to find a real solution for the problem by understanding why this logic was implemented the way it is. When you have performance problems, take a look at bug HHH-2272 in the hibernate jira. There I describe performance problems when inserting large amount of complex transient objects and a preliminary solution for that. Markus Heiden ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
Re: [hibernate-dev] Memory consumption
Hi Emmanuel, You need it for the post commit insert event. I know, but during the execution of "post commit" code of the EntityInsertAction only the id of the instance is needed and this should be retrievable after a flush. So in all cases there is no need to keep the reference to the instance after flushing. But we could optimize that if there is no such event. Anyway this solution would be sufficient for first. Or does hibernate keeps references to instances after a flush somewhere else too? Shall I create a JIRA issue? Markus Heiden ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev
Re: [hibernate-dev] Memory consumption
Hi Shawn, I experienced some time ago, that turning off the 2nd level could help getting rid of memory consumption problems, but wasn't able to track down the problem exactly. Your problem is the same problem as mine. As a solution I suggested to cut the references to the instances (application objects) in all Entity*Actions to be able to garbage collect the instances when they are no more needed by the application. The Entity*Actions would still be in ActionQueue.executions but this memory consumption should be acceptable. As a workaround turning off the query cache works for this problem too (at least if the Entity*Actions have hasAfterTransactionCompletion() == false), because the Entity*Actions aren't cached at all in ActionQueue.executions (as you already described). Markus Heiden ___ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev