And you should also dispose your transaction.

On Mon, May 30, 2011 at 9:06 AM, Oskar Berggren <[email protected]>wrote:

> The sessionfactory isn't intended to be instantiated on each request.
> What happens if you dispose the factory on each iteration?
>
> /Oskar
>
> 2011/5/27 dceder <[email protected]>:
> > I am using NHibernate 2.1.0.2002.
> >
> >
> > I have a simple test case which opens a session factory, then opens a
> > session, saves a record to a table, and closes the session. When I run
> > this as a web page from a stress test tool, the memory increases
> > significantly and eventually I get an OutOfMemoryException.
> >
> > This is the code(very straightforward):
> >
> >           NHibernate.Cfg.Configuration config = new
> > NHibernate.Cfg.Configuration();
> >            config.Configure("C:\\16580\\MemoryLeakWeb\\Test16580\
> > \nHibernate.config");
> >            config.AddFile("C:\\16580\\MemoryLeakWeb\\Test16580\
> > \Test.hbm.xml");
> >            ISessionFactory sessionFactory =
> > config.BuildSessionFactory();
> >            using (ISession session = sessionFactory.OpenSession())
> >             {
> >                    try
> >                    {
> >                        ITransaction tx = session.BeginTransaction();
> >                        TestType testType = new TestType();
> >                        testType.TestTypeField = 12;
> >                        session.Save(testType);
> >                        tx.Commit();
> >                    }
> >                    catch (Exception ex)
> >                    {
> >                    }
> >            }
> >
> > Now, I seem to recall that this was supposed to have been fixed:
> >
> http://groups.google.com/group/nhusers/browse_thread/thread/ad3090edcfb115ef
> >
> > What is the status on this? Is this till a bug in 2.1?
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> [email protected].
> > For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>


-- 
Ramon

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to