Reputation: 419
I am using NHibernate 2.2 with c# 3.5 and VS2008,
The problem is when I close the Nhibernate Session object, the memory is not released. even I call GC.Collect() after every close, but nothing is getting freed up
How can I force NHibernate to release the objects loaded in session when session is closed?
thanks
Upvotes: 7
Views: 2170
Reputation: 16393
There are a number of things which could prevent garbage collection actually occurring even if you call GC.Collect();
. For example if other objects which are still alive and in use are holding a reference to something you no longer want, then the object will be kept alive.
Also don't forget that a portion of the memory used will be the objects that NHibernate has returned fro the database for you.
Upvotes: 1
Reputation: 8381
Use Dispose instead of close. (Not only for Session, but for every object implementing IDisposable in .net)
Upvotes: 1