NHibernate Memory Leak

My company has an ASP.Net application that runs out of memory and eliminates exceptions from memory in just a couple of days of activity of our clients. I can reproduce the error in our test environment, and I created a hanging dump using adplus. When I looked at the largest / largest objects on the heap, I noticed that we have over 500,000 NHibernate.SqlCommand.Parameter objects. It may not be right! We had 33 shared instances of sessionfactories, and we have 1 sessionfactory for each client database. The version of nhibernate we are using is 2.1.0.4000.

We disabled the second level cache, request plan cache and request cache. We still see 500,000 NHibernate.SqlCommand.Parameter in a memory dump.

Is there any body of this behavior?

+4
source share
1 answer

We have a similar problem with our application (NHibernate 2.1.2.4000, ODP.net 2.111.7.0 on Windows 7). When we insert data into the database, we end up with a huge memory leak and descriptor:

for (int i=1;i<10000;i++) { using (var session = _sessionFactory.OpenSession(); { var tx = session.OpenTransaction() // insert a few rows into one table tx.Commit() } } 

The only solution is to set Enlist = false in the connection string or use OracleClientDriver instead of OracleDataClientDriver. This issue did not occur in NHibernate 1.2. When we tried this with TransactionScope, there was an even worse communication leak.

+1
source

Source: https://habr.com/ru/post/1309711/


All Articles