The loaders in AbstractEntityPersister require a large amount of memory and are not always necessary. The solution for delaying the creation of certain loaders can be used on the other loaders too.
In our scenario wih about 1000 Mappings the SessionFactory needs only 66 MByte instead of 151 MByte.
Very interesting, I’d be happy to look into this.
Is there anything specific in your mappings that would help me reproduce this?
The only thing specific are longer column names. I am attaching
1. testcase project
2. two screen shots of memory footprint of SingleTableEntityPersister. With and without patch.
The difference is about 20 kb or about 20 percent of the total memory of SingleTableEntityPersister. In our large projects with about 1000 Mappings this is significant.
Many thanks, that’s very helpful. I’ll see what we can do: I’m taking your patch as a starting point but while at it there’s some additional things I’d like to re-work, I hope you don’t mind.
Also worth noting: I just spent a week on other memory-saving patches; the other ones are unrelated with SingleTableEntityPersister, but I expect that when we’ll combine them all in the next release there should be many benefits in terms of memory overhead.
Great! Thanks very much for this.