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
Use Dispose instead of close. (Not only for Session, but for every object implementing IDisposable in .net)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With