i have a simple asp.net website that uses nhibernate. after a while the server goes out of ram. the sql and iis use up a lot of memory. i disabled cahceing and viewstate but still the system goes out of memory. this is my hibernateutil class
public static class HibernateUtil { static ISessionFactory sessionFactory; static ISession CurrentSession { get { return (ISession)HttpContext.Current.Items["HibernateSession"]; CallContext.GetData(SESSION_KEY); } set { HttpContext.Current.Items["HibernateSession"] = value; } } static HibernateUtil() { try { Configuration cfg = new Configuration(); cfg.Configure(typeof(HibernateUtil).Assembly, "EACPersistence.hibernate.cfg.xml");
cfg.AddClass(typeof(EACPersistence.Mappings.MyClass)); string connection = System.Configuration.ConfigurationManager.ConnectionStrings["EACConnectionString"].ConnectionString; cfg.SetProperty("connection.connection_string", connection); sessionFactory = cfg.BuildSessionFactory(); } catch (NHibernate.HibernateException ex) { } } public static ISessionFactory getSessionFactory() { return sessionFactory; } public static ISession getCurrentSession() { if (CurrentSession == null || CurrentSession.Transaction.IsActive == false) { CurrentSession = sessionFactory.OpenSession(); } return CurrentSession; } } }
|