Memory leak in AbstractBatcher with Generated Properties

Description

Using Hibernate 3.2 GA with Entity Manager and Annotations, I have a batch job that inserts several thousands of objects for a class with a @Generated property. The job results in a memory leak in the AbstractBatcher class.

The problem appears to be in the method processGeneratedProperties in AbstractEntityPersister. This method closes the result set for the generated property query and calls session.getBatcher().closeStatement() to close the statement instead of session.getBatcher().closeQueryStatement to close both the statement and the result set. The result is that even though the result set is closed, it is not removed AbstractBatcher's resultSetsToClose HashSet.

Even though the batch job commits and clears the session every 200 rows, over time the leaked result sets in resultSetsToClose results in an OutOfMemory problem.

I've changed the code in AbstractEntityPersister.processGeneratedProperties to call session.getBatcher().closeQueryStatement and the same job then runs to completion without the memory leakage.

I noticed that this method in AbstractEntityPersister has had a recent change to fix a similar problem for issue HHH-1750, so I wanted to verify that this fix is the right approach.

Environment

Hibernate 3.2.0 GA; Oracle 10g; Java 1.5

Activity

Show:
Michael Werle
May 22, 2007, 2:26 AM

The patch submitted with fixes this issue, as well.

Gail Badner
October 19, 2007, 12:50 AM

This issue was fixed by the fix for HHH-2627.

Assignee

Gail Badner

Reporter

JayJ

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure