-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: URGENT... NHibernate Memory management problem
PostPosted: Fri Jan 12, 2007 3:24 pm 
Newbie

Joined: Sun Nov 05, 2006 10:19 am
Posts: 13
I'm having a huge problem with NHibernate and memory management.

I've made an ASP.NET application using NHibernate...Everything went perfect on small database. When the database became bigger (~2-3 GB)...the process w3wp.exe increases his memory a lot.

I'm very sure I'm closing the session at the end of each request because I've checked with the debugger.

Also the lazy is set to true.

A small example....to imagine exactly...I'm using a custom memberhsip provider in the authentication model...

So when I start the application and I'm redirected to the login page...w3wp.exe has 40 MB...ok...now when I log in and go to an empty page(just for test) the w3wp.exe process goes to 110MB....

For testing I've put only 2 users and 2 roles in the tables for authentication....the other tables has info which makes the database to be around 2-3 GB....

I'm very positive that I'm closing the session because I've checked with the debugger like I've said..

The code is:


Code:
public static void CloseSession()
        {
            HttpContext context = HttpContext.Current;
            ISession currentSession = context.Items[CurrentSessionKey] as ISession;

            if (currentSession == null)
            {
                // No current session
                return;
            }

            currentSession.Close();
            currentSession.Dispose();
            context.Items.Remove(CurrentSessionKey);
        }


The strange thing is that the memory goes up after I finish the above method to run (the target page is an empty one)...


The last lines from the log are:
2007-01-12 21:18:42,343 [5920] DEBUG NHibernate.Impl.SessionImpl [(null)] - disconnecting session
2007-01-12 21:18:42,343 [5920] DEBUG NHibernate.Connection.ConnectionProvider [(null)] - Closing connection
2007-01-12 21:18:42,343 [5920] DEBUG NHibernate.Impl.SessionImpl [(null)] - transaction completion
2007-01-12 21:18:42,343 [5920] DEBUG NHibernate.Impl.SessionImpl [(null)] - running ISession.Dispose()
2007-01-12 21:18:42,343 [5920] DEBUG NHibernate.Impl.BatcherImpl [(null)] - running BatcherImpl.Dispose(true)
2007-01-12 21:18:42,343 [5920] INFO NHibernate.Impl.SessionFactoryImpl [(null)] - Closing

Why it has this problem on huge databases even if I've made the test with login system which uses two tables (not all tables)?.....it's like the session stays in memory...I've forced the GC to delete it...I know you can't be 100% percent but is unlikely that at each scenario of accessing the database to grow so much the memory... I've "succedded" to reach 800 MB....I repeat..lazy is set to true...

It's so bad NHibernate on very big databases systems?!
Maybe I'm making a mistake somewhere...Please any idea?

Thx


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 12, 2007 3:58 pm 
Newbie

Joined: Sun Nov 05, 2006 10:19 am
Posts: 13
I forgot to tell you that also sql server process has between 300 - 400 MB....Now I'm running with 2 GB RAM on servers to be sure it's staying up...

There are simple selects....I'm sure I don't have a join query with more than 2 tables...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 12, 2007 7:51 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
Please run a profiler and see what is taking the memory.
Without knowing more details, we will have hard time helping you solve this issue.

Do you have the 2nd level cache enabled?
Are you certain that you are not loading more objects than you should?
What version on NH?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.