开发者

nhibernate does not release memory after session closes

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 fre开发者_如何学运维ed 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜