Closed
Description
Philippe Marschall opened SPR-9264 and commented
We analysed the memory usage of our application and found a lot of empty LinkedHashSet/Collections.synchronizedSet in the following three cases:
org.springframework.beans.factory.annotation.InjectionMetadata.injectedElements
*
```
org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.LifecycleMetadata.initMethods
*
```
org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.LifecycleMetadata.destroyMethods
There are two things that can be done to address this:
1. Creating a LinkedHashSet of the "right" size, eg. the default capacity is 16 but the exact capacity is known in advance
1. If the argument is empty then we use Collections.emptySet() which is a constant so no additional memory is used. Since it's immutable there is no need for the Collections.synchronizedSet wrapper.
Affects: 3.1 GA