Skip to content

Conversation

@dev3way
Copy link
Contributor

@dev3way dev3way commented Jan 3, 2025

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.
image

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.


@beikov beikov changed the title HHH-19005 Memory leak modify String to StringBuilder HHH-19005 Reduce memory usage for JSON string literals in BasicFormatterImpl Feb 11, 2025
@dev3way dev3way requested a review from gavinking February 11, 2025 14:39
@hibernate-github-bot
Copy link

hibernate-github-bot bot commented Feb 11, 2025

Thanks for your pull request!

This pull request appears to follow the contribution rules.

› This message was automatically generated.

@dev3way
Copy link
Contributor Author

dev3way commented Feb 11, 2025

@gavinking Is there any other things to check?

@dev3way dev3way requested a review from gavinking February 11, 2025 15:22
Copy link
Member

@gavinking gavinking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, great, thanks.

@beikov
Copy link
Member

beikov commented Feb 11, 2025

@dev3way dev3way force-pushed the feature/HHH-19005 branch 3 times, most recently from 6653578 to 72ea36d Compare February 12, 2025 04:31
@dev3way dev3way requested a review from gavinking February 12, 2025 04:32
@dev3way
Copy link
Contributor Author

dev3way commented Feb 12, 2025

@gavinking @beikov Modified code style and commit message. Please, review again this pr

@dev3way dev3way force-pushed the feature/HHH-19005 branch 2 times, most recently from 72ea36d to 15678d4 Compare February 12, 2025 23:48
@dev3way
Copy link
Contributor Author

dev3way commented Feb 13, 2025

@gavinking @beikov Could you please check and merge?

@beikov beikov merged commit bdc0205 into hibernate:main Feb 13, 2025
6 of 7 checks passed
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

Successfully merging this pull request may close these issues.

3 participants