Significant Memory Increase After Upgrading from Spring Boot 3.3.5 to 3.4.4

Description

After upgrading our Spring Boot starter from 3.3.5 to 3.4.4, we observed a significant increase in memory usage. Previously, with Spring Boot 3.3.5 and Hibernate 6.5.3, the used memory was around 300MB. However, after the upgrade, where Hibernate 6.6.11 is now being used, the memory consumption has increased to 2000MB.

One key difference is that in 3.3.5, the JpaQueryParserSupport parser was being used, whereas in 3.4.4, the ANTLR parser is being used. This could be a potential cause of the issue.

Steps to Reproduce:

  1. Prepare a Spring Boot Project Spring Boot 3.3.5 (Which internally will use Hibernate 6.5.3) where multiple Repositories should be there with enough HQL Queries to identify the difference.

  2. Run the application and capture memory usage with any of the profiler (VisualVM, Jprofiler).

  3. Upgrade to Spring Boot Starter 3.4.4 (Which will internally use Hibernate 6.6.11).

  4. Compare memory usage with initialization and during runtime.

  5. Also, you will see the spike in the memory usage while this log gets printed on console “Hibernate is in classpath; If applicable, HQL parser will be used."

Expected Behavior:

  • Memory usage should remain within a reasonable range without unexpected spikes.

Please suggest potential optimizations or configurations to mitigate this issue.

Live Objects
With 6.5.3

With 6.6.11



Attachments

2

Activity

Show:

Thomas Heigl 7 hours ago

Unfortunately, both of the reproducers have external dependencies. If you want to increase your chances that someone on the Hibernate team will look into this, I’d recommend removing Spring from the equation and create a reproducer using only the Hibernate test-case templates.

Thomas Heigl 7 hours ago
Edited

There is at least one related issue:

The reproducer on this issue also uses subqueries.

Hardik Raja 10 hours ago

Here is a POC project that reproduces the issue. I have identified a specific query that appears to cause a memory leak internally in Hibernate 6.6.11. Please refer to the README.md of this project for details and follow the steps to reproduce the issue.

Details

Assignee

Reporter

Worked in

Affects versions

Priority

Created 4 days ago
Updated 7 hours ago