Skip to content

High Memory Usage After Upgrading to Spring Boot 3.4.4 #44931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Hardikraja opened this issue Mar 28, 2025 · 3 comments
Closed

High Memory Usage After Upgrading to Spring Boot 3.4.4 #44931

Hardikraja opened this issue Mar 28, 2025 · 3 comments
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid

Comments

@Hardikraja
Copy link

Bug Report: High Memory Usage After Upgrading to Spring Boot 3.4.4

Problem Description

After upgrading from Spring Boot 3.3.5 to Spring Boot 3.4.4, we observed a significant increase in memory consumption in our application.

  • In Spring Boot 3.3.5, Hibernate 6.5.3 was used, and the JpaQueryParserSupport parser was active.
  • In Spring Boot 3.4.4, Hibernate 6.6.11 is used by default, and the query parser has changed to ANTLR parser.
  • I suspect that this change might have resulted in our application's used memory increasing from 300MB to 2000MB.
  • This memory spike occurs just by initializing the project While parsing HQL to SQL, without executing any queries.

Steps to Reproduce

  1. Set up a Spring Boot 3.3.5 Application:

    • Create a Spring Boot project using Spring Boot 3.3.5.
    • Use spring-boot-starter-data-jpa with Hibernate 6.5.3 (default in 3.3.5).
    • Have approximately 50 HQL queries defined across various repositories.
    • Connect the application to a relational database.
    • Start the application and monitor memory usage.
  2. Upgrade to Spring Boot 3.4.4:

    • Update the Spring Boot starter parent from 3.3.5 to 3.4.4 in pom.xml or build.gradle.
    • Ensure that Hibernate 6.6.11 (default in 3.4.4) is being used.
    • Start the application again and observe the memory usage difference.

Observed Behavior with our application

  • Before Upgrade (Spring Boot 3.3.5 with Hibernate 6.5.3): Memory usage stays around 300MB.
  • After Upgrade (Spring Boot 3.4.4 with Hibernate 6.6.11): Memory usage spikes to 2000MB, while project initialization

Expected Behavior

Memory consumption should remain within a reasonable range after upgrading to a newer version of Spring Boot and Hibernate.

Workaround Considered

Since we urgently need to upgrade due to security vulnerabilities, we are considering excluding Hibernate 6.6.11 and manually using Hibernate 6.5.3.

  1. Is it advisable to use Hibernate 6.5.3 with Spring Boot 3.4.4 instead of the default Hibernate 6.6.11?
  2. Will this cause compatibility issues with Spring Boot 3.4.4 or Spring Data JPA?
  3. Are there any known performance regressions in Hibernate 6.6.11 that could be causing this?

This issue has been reported in the Hibernate JIRA: HHH-19292 for further investigation.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 28, 2025
@shivammm21
Copy link

@spring-projects-issues @Hardikraja Please assign this issue to me.

After upgrading from Spring Boot 3.3.5 to 3.4.4, the application experiences a significant increase in memory usage, rising from 300MB to 2000MB. The key difference in this upgrade is the transition from Hibernate 6.5.3 to Hibernate 6.6.11, where the default query parser has shifted from JpaQueryParserSupport to an ANTLR-based parser. This change appears to be causing excessive memory consumption during HQL to SQL parsing, even before any queries are executed.

To address this issue, I will first confirm whether the new parser is responsible for the memory spike by profiling memory usage using tools such as VisualVM or Eclipse Memory Analyzer (MAT). If the ANTLR parser is indeed the cause, I will investigate whether rolling back to Hibernate 6.5.3 while keeping Spring Boot 3.4.4 remains a viable option without causing compatibility issues. Additionally, I will explore possible optimizations in Hibernate configurations, such as query caching and parser settings, to mitigate excessive memory consumption.

If necessary, I will report findings to the Hibernate and Spring Boot teams and suggest potential fixes or workarounds. I will work on debugging and resolving this issue and provide updates on the progress.

@wilkinsona
Copy link
Member

Since we urgently need to upgrade due to security vulnerabilities

Which vulnerability is driving a 3.3 to 3.4 upgrade?

Is it advisable to use Hibernate 6.5.3 with Spring Boot 3.4.4 instead of the default Hibernate 6.6.11?

I don't think we'd ever advise it, but if needs be then it's worth a try. Note that it hasn't been tested and we wouldn't officially support Hibernate 6.5 with Boot 3.4. That said, the upgrade from Hibernate 6.5 to 6.6 looks to have been a smooth one.

Will this cause compatibility issues with Spring Boot 3.4.4 or Spring Data JPA?

Unknown. You should test it in your application.

Are there any known performance regressions in Hibernate 6.6.11 that could be causing this?

We're not aware of any, but the Hibernate team will be much better-placed to answer this.

This issue has been reported in the Hibernate JIRA: HHH-19292 for further investigation.

I'd recommend updating that issue with a complete yet minimal sample that reproduces the problem. In particular, that sample should provide the "multiple Repositories … with enough HQL Queries to identify the difference".

I'll close this one on the Spring Boot side as I don't think there's anything for us to do.

/cc @mp911de for awareness on the Spring Data side of things.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Mar 28, 2025
@wilkinsona wilkinsona added status: invalid An issue that we don't feel is valid for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 28, 2025
@Hardikraja
Copy link
Author

Here is the POC Project which reproduces the issue

https://github.com/Hardikraja/hibernate-6.6.11-case-with-subquery

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

4 participants