ehm... 500 to 1000 what ? Are you sure that you really need 500 to 1000 sessionFactories ? Have you 500 to 1000 different schema in your application used by 30 to 50 concurrent users ?
On Thu, Feb 10, 2011 at 9:54 AM, Byton <[email protected]> wrote: > I'm using NHibernate (3.0.0.GA) in a client/server application where the > server will access multiple databases using a SessionFactory for each > database. For smaller installations this seems to work fine but for larger > installations (500-1000 databases but only 30-50 users total) memory usage > is becoming a problem and the server will eventually crash with an 'Out of > memory' exception. (32-bit environment so this happens when memory usage > reaches 1.2-1.5 gigabytes). > > It seems to be the SessionFactory instances and related db-mapping > information that is the main cause here and my first solution was to call > Dispose on one of the existing SessionFactory instances before creating a > new one when a certain number (100) of instances had been created. The > problem was that the SessionFactory instance was not removed from memory > even after being Disposed and I'd still get an 'Out of memory' condition > eventually. > > I ended up having to do it like this: > > sessionFactoryForRemoval.Dispose(); > GC.SuppressFinalize(sessionFactoryForRemoval); > > After this the memory would actually be released, but shouldn't the call to > Dispose be enough to have the memory released? > > Also, is this really a good way of doing 'NHibernate with multiple > databases'? It seems that there is a risk of me disposing of a > SessionFactory while another request to the server is using an ISession from > that SessionFactory...will that be a problem? > > > Leif Vaarum > > -- > 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. > -- Fabio Maulo -- 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.
