The bean class reference is shared by the classloader so it doe snot add up to the memory consumed by Hibernate Validator, correct?
Right. And the class data is even held in the perm gen, but I will investigate this a little more.
I am actually thinking that we could have a specialized implementation of BeanMetaData that has no state. We would save up on:
* all those unnecessary references
* we could reuse the same instance to represent all non validated classes and save up on the BeanMetaDataManager cache
The problem is that the bean meta data also contains the bean descriptor for the unconstrained entity. For nothing else it contains the bean type itself. It is perfectly ok to ask for the bean descriptor for an unconstrained bean as well. If we go for the specialized implementation we need to find a solution for this as well. I am not sure its worth it. The memory footprint is really small if you take the class data out of the picture. I will add some actual numbers as well. Also the bean meta data cache uses soft references now.
Right. And the class data is even held in the perm gen, but I will investigate this a little more.
The problem is that the bean meta data also contains the bean descriptor for the unconstrained entity. For nothing else it contains the bean type itself. It is perfectly ok to ask for the bean descriptor for an unconstrained bean as well. If we go for the specialized implementation we need to find a solution for this as well. I am not sure its worth it. The memory footprint is really small if you take the class data out of the picture. I will add some actual numbers as well. Also the bean meta data cache uses soft references now.