1) Do you have the 2nd level cache turned on?

2) How are you determining that the application *uses* 1gb of ram? The .Net 
Runtime *never releases memory*. The vagrancies of Windows virtual memory 
and Garbage Collection 
<http://blogs.msdn.com/b/oldnewthing/archive/2010/08/09/10047586.aspx> are 
far too deep a discussion for here and now.  But if you're simply looking 
at the number in Task Manager it can be very deceiving.
 
3) If you are in-fact leaking objects you'll be seeing your memory usage 
continue to climb.

On Tuesday, December 1, 2015 at 10:00:38 AM UTC-5, JK wrote:
>
>
> I use the class below to access mysql. after a few queries, the 
> application pool of IIS 7.5 increases to around 1 GB of RAM. I checked that 
> the dispose method of the class is always executed. Why is this happening? 
> And 'normal connections mysql remain in  'sleep' ?
>
> Thank you
>
> JK
>
> public class RepositoryBase: IDisposable
> {
>     protected ISession _session = null;
>     protected ITransaction _transaction = null;
>     public Boolean extension_transaction = false;
>    
>    
>     
>     
>     public RepositoryBase(string connectionString)
>     {
>         
>         _session = 
> NHibernateMultipleHelper.GetCurrentSession(connectionString);
>         _transaction = _session.BeginTransaction();
>     }
>
>     public RepositoryBase(ISession session)
>     {
>         _session = session;
>     }
>
>     #region Transaction and Session Management Methods
>
>     public void BeginTransaction()
>     {
>         _transaction = _session.BeginTransaction();
>     }
>
>     public void CommitTransaction()
>     {
>         // _transaction will be replaced with a new transaction
>         // by NHibernate, but we will close to keep a consistent state.
>             _transaction.Commit();
>             CloseTransaction();
>     }
>     public virtual object GetById(Type objType, object objId)
>     {
>         return _session.Get(objType, objId);
>     }
>     public void RollbackTransaction()
>     {
>         // _session must be closed and disposed after a transaction
>         // rollback to keep a consistent state.
>         _transaction.Rollback();
>
>         CloseTransaction();
>         CloseSession();
>     }
>
>     private void CloseTransaction()
>     {
>         _transaction.Dispose();
>         _transaction = null;
>     }
>
>     private void CloseSession()
>     {
>         _session.Clear();
>         _session.Close();
>         _session.Dispose();
>         _session = null;
>     }
>
>     #endregion
>
>     #region IRepository Members
>
>     public virtual IQuery getSQLQuerySession(ref IQuery query, string sql)
>     {
>
>         return _session.CreateSQLQuery(sql);
>
>     }
>
>     public virtual IQuery getQuerySession(ref IQuery query, string sql)
>     {
>
>         return _session.CreateQuery(sql);
>         
>     }
>     public virtual IQuery setQuerySession(string sql)
>     {
>
>         return _session.CreateQuery(sql);
>
>     }
>     
>     public virtual void Save(object obj)
>     {
>         _session.SaveOrUpdate(obj);
>         
>     }
>
>     public virtual void Persist(object obj)
>     {
>         _session.Persist(obj);
>
>     }
>
>     public virtual void Delete(object obj)
>     {
>         
>         _session.Delete(obj);
>         
>     }
>
>     public virtual void Evict(object obj) {
>         _session.Evict(obj);
>
>     }
>
>    
>
>     #endregion
>
>     #region IDisposable Members
>
>     public void Dispose()
>     {
>         if (_transaction != null)
>         {
>             // Commit transaction by default, unless user explicitly rolls 
> it back.
>             // To rollback transaction by default, unless user explicitly 
> commits,
>             // comment out the line below.
>             
>                 CommitTransaction();
>             
>         }
>
>         if (_session != null)
>         {
>             _session.Flush(); // commit session transactions
>             CloseSession();
>         }
>     }
>
>     #endregion
> }
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to