Skip to content

Memory leak (large) when using EclipseLink with mssql-jdbc drivers #2412

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

Open
stefan-esq opened this issue May 8, 2025 · 0 comments
Open

Comments

@stefan-esq
Copy link

Describe the bug
Using Eclipselink with recent versions of the mssql-jdbc driver is resulting in a memory leak.
This appears to be due to the fact that recent versions of the mssql-jdbc driver has had a reconnect listener added. The reconnect listener is added to the SQLServerConnection when a PreparedStatement is created and removed from the SQLServerConnection when the PreparedStatement is closed.
It appears however, that EclipseLink is not closing the PreparedStatement, resulting in a memory leak.
After upgrading to Java 17 and running a stress test, we found SQLServerConnections leaking GBs of heap due to having a lot of reconnect listeners.

Image

It appears this is happening after a change in the mssql-jdbc driver, see microsoft/mssql-jdbc#2364.

To Reproduce
It appears the problem occurs when using EntityManager.persist(entity) and the transaction is commited.
Used versions:

  • EclipseLink 4.0.5
  • mssql-jdbc 12.10.0.jre11

Steps/resources to reproduce the behavior:
Please see the attached zip file, containing a sampple project and instructions to reproduce.
demo.zip

Expected behavior
Memory usage should stagnate, not keep increasing until the application runs out of memory.

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant