NHibernate 1st level cache

618 Views Asked by At

Context: I am working on a .NET 3.5 Windows application that crashes once RAM has been completely filled by NHibernate 1st level caching.

Question 1: Does NHibernate's 1st level caching algorithm perform memory checks to ensure sufficient space exists?

Question 2: When using the Evict method, are the following pseudo code steps correct?

1 - session.Query

2 - save query results

3 - session.Evict

4 - return saved results

Update

In the context where sessions are created at the start of the application and disposed off only once application ends, I wish to control NHibernate's first level cache size. NHibernate documentation explains in details how cache works and how to manage it but makes no mention of cache size, which is an issue in my case.

Question 3: Is it possible to know the cache size of session (to subsequently clear it if needed)? Alternatively, is possible to set a limit on the size of the cache Nhibernate can use application wide?

1

There are 1 best solutions below

0
On

Generally you should not use single session for your app. Usually you should create one per single unit of work. There multiple examples on session management in desktop apps: one two