SpringSource/spring-framework — pull request #37 by marschall (2012-02-13 18:29:25+00:00)
Title: Small memory fixes

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

This fix should address this issue by:
1. Creating a LinkedHashSet of the "right" size, eg. the default capacity is 16 but we know the exact capacity that we need in advance
2. If the argument is empty then we use Collections.emptySet() which is a constant so no additional memory is used. Since it's immutable we also save ourselves the Collections.synchronizedSet wrapper.

Should I additionally open an issue?