Currently several classes in the framework use ConcurrentReferenceHashMap with soft references for caching. Unfortunately soft references only get cleared when the JVM is completely out of memory making it appear that Spring is consuming a lot of resources.
We could create a dedicated MemoryCache abstraction with additional bounds to ensure that no individual cache is consuming too much memory.
Another, perhaps simpler approach, could be to clear caches after the ApplicationContext has loaded. The ResolvableType cache especially could benefit from this approach.
#16851 Reduce BeanDefinition cloning in AbstractBeanFactory.getMergedBeanDefinition
#18357 ReflectionUtils cache uses up a fairly big chunk of heap even
0 votes, 5 watchers
The text was updated successfully, but these errors were encountered: