Memory leak in BeanValidationEventListener

Description

When doing a lot of inserts/updates with JPA entitymanager, a lot of org.apache.bval.jsr.valueextraction.ValueExtractors instances are created which are not removed by the garbage collector.

See attached images, the sampler shows 12+GB memory usage by these bean validation objects.
When disabling bean validation by setting validation-mode to NONE in persistence.xml, the issue does not arise.

Environment

None

Activity

Show:
Sanne Grinovero
October 22, 2020, 12:49 PM

Hi , I’ve transferred this issue to the Hibernate Validator project. Could you confirm the version you’ve been using?

Sanne Grinovero
October 22, 2020, 12:51 PM

Ah, I see now you’re using Apache BVal ? Sorry we don’t maintain that here - unless the problem is in Hibernate ORM?

I would recommend please try Hibernate Validator first, and let us know. Or report this to the Apache JIRA.

Guillaume Smet
October 22, 2020, 1:07 PM

Yeah I think the issue is in Apache BVal.

Creating Validators based on new contexts should be a very lightweight operation and it looks like they are creating quite a lot of objects in the process and keeping references to them.

And a ValidatorFactory shouldn't keep track of all the Validators created as a high number of them can be created dynamically.

Give Hibernate Validator a try and see if you have the same issue. I bet you won't.

Assignee

Unassigned

Reporter

Sven Jochems

Labels

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Priority

Minor
Configure