nhibernate / fluent-nhibernate

Fluent NHibernate!
BSD 3-Clause "New" or "Revised" License
1.66k stars 686 forks source link

Memory leak in NHibernate 5.5.0 compared to 5.4.9 #712

Closed Bogatinov closed 2 months ago

Bogatinov commented 2 months ago

Hi friends, I'm writing this issue to report a Memory leak on NHibernate objects when upgrading from v5.4.9 to v5.5.0 (and v5.5.2)

Configuration

I haven't tested to build a custom FluentNHibernate DLL with the 5.5.2 package and see if that resolves the issue.

Story

Comparing NHibernate v5.4.9 and v5.5.0 there seem to be +200MB after 16min of usage of our app. I tested this on a Staging environment, and after 2 weeks, our testers reported that the VM was running slow.

Checked that the RAM was full with Application Insights Metrics, while the app RAM usage was around 6GB. This looked weird since +200MB is a small difference, but the more users request for SQL Server 2016/2019 data, the more this increased.

I reverted to v5.4.9 and the app stayed on around 2GB for the last 2 months.

Repository

TBD - currently setting up...

do let me know in which direction should I test it, since I'm noticing that most types with high Delta difference are part of common usages in NHibernate APIs.

Benchmarks

It's a project I can not share because of NDA reasons. The benchmark is applying automatic 10 actions in 16 min usage, by 1 user.

v5.4.9

image

v5.5.2

image

Comparison in objects

For the same benchmark test case, v5.5.2 generated 150k more objects (~15MB more) image

than v5.4.9 image

I re-tested this in JetBrains dotMemory and received 160k - 211k on the same benchmark image

where most types are interfaces image