Hi,
I have searched the forum before I decided to open this thread. There are already two threads that describe the same problem I am facing, but unfortunately there are no answers:
https://forum.hibernate.org/viewtopic.php?f=1&t=962074https://forum.hibernate.org/viewtopic.php?f=1&t=987196Let me describe what I am doing: I have a native sql query which I execute quite often (about 500 000 times). After 100 executions, i call flush() and clear() on the session to prevent an out of memory exception. The problem is that even with the flush() and clear() my app crashes after some time because there is no space any more on the heap.
I used a memory profiler to find out that there are a lot of BulkOperationCleanupAction objects hanging around on the heap. The number of those objects is approximately equal to the times I execute the native SQL query. After I saw that, I took a look at the source code of hibernate. What I found there was very interesting: A session has an ActionQueue which holds several lists for actions. One of this lists contains the BulkOperationCleanupAction objects.
Next i took a look at the clean() method of the session. In there the clean() method of the ActionQueue is called, which then calls clear on the internal lists, except for the one containing the BulkOperationCleanupActions:
Code:
updates.clear();
insertions.clear();
deletions.clear();
collectionCreations.clear();
collectionRemovals.clear();
collectionUpdates.clear();
Why is the BulkOperationCleanupAction list not cleared? What is the solution to the above problem? Is there any way to clear the executions too? Or should this be done in a completely different way?
I don't know if it is related to the above problem, but I am using statement caching. Furthermore I found out that the BulkOperationCleanupAction list is cleared when the transaction is commited.