Not an Issue
Details
Details
Assignee
Unassigned
UnassignedReporter
Steven Thacher
Steven Thacher(Deactivated)Components
Affects versions
Priority
Who's Looking?
Open Who's Looking?
Created April 12, 2011 at 7:26 AM
Updated July 14, 2011 at 11:05 AM
Resolved July 14, 2011 at 11:05 AM
We have discovered a small memory leak in our application, and we've been able to track it down to NHibernate using JetBrains dotTrace. It appears that as we make queries, the SessionFactoryImpl class continues to grow. The object within SessionFactoryImpl that seems to be holding on to the most memory is the SoftLimitMRUCache. This issue seems similar to which was apparently resolved in 1.0.3, but I continue to see the problem in version 2.0.
I've tried various approaches to clearing this cache, but nothing has worked for me thus far. I've tried the following:
Attempt 1: Write a clear cache function that clears everything in the session factory:
_sessionFactory.EvictQueries();
foreach (Type type in _sessionFactory.GetAllClassMetadata().Keys)
_sessionFactory.Evict(type);
foreach (string role in _sessionFactory.GetAllCollectionMetadata().Keys)
_sessionFactory.EvictCollection(role);
Attempt 2:
Set the FlushType of our Session, then flush and clear the session before each query.
Attempt 3:
Change configuration properties in the config XML file and turn off the 2nd level cache.
As I said, none of these attempts were successful.