memory when using default_batch_fetch_size

Description

As since NH3+ setting the default_batch_fetch_size to something has very bad impact on memory as soon the SessionFactory is created. I'm using 3 sessionfactories in an web app (I'm accessing 3 db's). It uses 250MB without the setting but 750MB (default_batch_fetch_size=16) with the setting. When I switch back to 2.1.2 the problem is gone. My webserver recycles because the private memory is reached!

grtz,
Kris

Environment

None

Activity

Show:

Alex Zaytsev July 9, 2024 at 12:25 AM

Moved here.

Filip Duyck July 16, 2014 at 1:13 PM

It's been almost a year. Is anyone ever going to look at this?

Filip Duyck September 13, 2013 at 7:29 AM

In addition to what Kris said, I'd like to share some results from our dotTrace profiling session.

Performance trace can be seen at http://i.imgur.com/McdRBpA.png – notice how in NHibernate 3, EntityLoader..ctor is called about 10x as much as in 2.1.2 (even though the calls to BatchingEntityLoader.CreateBatchingEntityLoader are more or less of the same order of magnitude).

We also did memory profiling which showed similar results, which you can see at http://i.imgur.com/t0VmfV2.png. In this trace, you can see that BatchingEntityLoader.CreateBatchingEntityLoader creates many, many more objects in 3.3.3 than it did in 2.1.2.

I have looked at the code of both methods but I can't really identify a change. Our setup for NH2.1.2 and NH3.3.3 use virtually the same configuration. The problem is, as Kris mentioned, amplified by the fact that we have default_batch_fetch_size set to 16 which causes more looping inside the CreateBatchingEntityLoader method, but this setting is the same during 2.1.2 and 3.3.3 testing.

Can anyone from the NH team shed a light on this? Especially the memory problem is killing us in production.

Fixed

Details

Assignee

Reporter

Labels

Components

Fix versions

Priority

Who's Looking?

Open Who's Looking?
Created September 12, 2013 at 8:45 PM
Updated July 9, 2024 at 12:30 AM
Resolved July 8, 2024 at 11:43 PM
Who's Looking?