Skip to content

Memory leak in NHibernate 5.5.0 compared to 5.4.9 #3608

Open
@Bogatinov

Description

@Bogatinov

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

  • dotNET Framework 4.8.1
  • NHibernate v5.4.9 and v.5.5.2
  • FluentNHibernate v3.4.0 with a binding redirect for NHibernate 5.5.0
  • AMD Ryzen 9 5950X with 32GB 3600Mhz RAM/Samsung 980 1TB
  • SQL Server 16.0.1000.6 and 15.0.4385.2 databases
  • We are using Session.Query<T>, Session.QueryOver<T> and Session.CreateSQLQuery("raw")
  • around 270 mapping classes for tables with FluentNHibernate

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 from May 25th.

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

368199764-0f5b3033-bd66-4604-bc87-e70d9af831c0

v5.5.2

368199625-7a0fb175-26c6-4718-b18d-bb7be551f8ca

Comparison in objects

For the same benchmark test case, v5.5.2 generated 180k more objects (~15MB more)
368204975-7668719b-326e-4013-9687-a99c56c07532

than v5.4.9
368204714-a2b6333d-b322-4097-8775-f79d202181de

I re-tested this in JetBrains dotMemory and received 160k - 211k on the same benchmark
368997869-06e3828f-78f3-40f0-8160-824a9ff1313d

where most types are interfaces
369003290-0bd3116e-6215-4725-9e62-acfdf5c848d1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions