When complex objects are verified, processedPathsPerBean always occupies a large amount of memory, causing OOM.

Description

During validation, the processedPathsPerBean always consumes more memory, regardless of whether there are actually valid constraints. In this case, hibernate occupies a large amount of memory. In the concurrent scenario, when the object size is large, OOM occurs. I think this is a bug, and some strategy should be taken to constrain the size of processedPathsPerBean, such as only validating if there is an actual constraint.

 

According to the analysis, traversableResolver and failingConstraintViolations occupy a large amount of memory during the verification process, but they can be used.
addProperty("hibernate.validator.enable_traversable_resolver_result_cache", "false") and addProperty("hibernate.validator.fail_fast", "true") to prevent them from consuming memory. But there is no way to reduce the memory footprint of processedPathsPerBean.

 

This is the result of one of our hprof memory analyses.

 

The demo code that is causing the problem is this, and run with -Xmx5M

Environment

jdk1.8 hibernate-validator 6.2.5final

Attachments

1

duplicates

Activity

Show:

Marko Bekhta May 31, 2024 at 7:12 AM

Hey, thanks for opening the ticket. I probably wouldn’t classify this as a bug since HV has to do that tracking. Also, see the linked issue. Once that is resolved, it should be possible to improve your case as well.

Details

Assignee

Reporter

Labels

Bug Testcase Reminder (view)

Bug reports should generally be accompanied by a test case!

Bug Testcase Reminder (edit)

Bug reports should generally be accompanied by a test case!

Participants

kamow
Marko Bekhta

Priority

Created May 30, 2024 at 1:57 AM
Updated May 31, 2024 at 7:12 AM