-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
HHH-19005 Reduce memory usage for JSON string literals in BasicFormatterImpl #9545
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
Conversation
1ff49aa to
259a9bb
Compare
hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/BasicFormatterImpl.java
Outdated
Show resolved
Hide resolved
hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/BasicFormatterImpl.java
Outdated
Show resolved
Hide resolved
|
Thanks for your pull request! This pull request appears to follow the contribution rules. › This message was automatically generated. |
53ef8d7 to
5703a00
Compare
|
@gavinking Is there any other things to check? |
gavinking
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, great, thanks.
|
Please fix the code style errors: https://github.com/hibernate/hibernate-orm/actions/runs/13266304414/job/37035063848?pr=9545 |
6653578 to
72ea36d
Compare
|
@gavinking @beikov Modified code style and commit message. Please, review again this pr |
72ea36d to
15678d4
Compare
|
@gavinking @beikov Could you please check and merge? |
15678d4 to
b29ef41
Compare
https://hibernate.atlassian.net/browse/HHH-19005
Hello.
When It is json, there are some memory leak.
These are the results of the modified code and the existing code when tested locally.

In the case above, there is no problem elsewhere, but the problem occurs at the point where JSON data is encountered after VALUES. From this point on, a String is created in the above code for all tokenized JSON data, creating a memory leak. This means that the larger the JSON, the more leaks it will create.
This problem doesn't normally occur, but it makes a difference if you are performing json. This occurs when tokenizing json and formatting it while passing the switch statement within the perform method. Therefore, it seems better to change this code to StringBuilder as shown below.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.