views:

44

answers:

2

Does the NHibernate session object use allot of server RAM?

It depends on website traffic, but does the session object get very big in terms of memory usage?

A: 

The ISession object is a very lightweight object, ISessionFactory not.

Oliver Hanappi
A: 

It can - it depends on how you're using it. The session is your unit of work, so typically only exists for a short period of time. It acts as your first level of cache, storing the entities that it has dealt with throughout its lifetime.

If you're keeping your sessions alive for a long time, they will potentially become more and more bogged down with cached entities. In certain scenarios, you can use ISession.Evict to remove an entity from the session if there's no reason for it to be kept in there.

HTH,
Kent

Kent Boogaart