thomas.kummer opened SPR-15220 and commented

Our server is creating (a lot) prototype beans programatically see code below:

@Autowired
    private AutowireCapableBeanFactory beanFactory;

    @Override
    public final ServiceStageProcessor newProcessor() {
        ServiceStageProcessor processor = create();    beanFactory.autowireBeanProperties(processor,AutowireCapableBeanFactory.AUTOWIR_NO, false);

        beanFactory.initializeBean(processor,
                processor.getClass().getSimpleName() + "@" + Integer.toHexString(processor.hashCode())); // this call causes the memory leak
        return processor;
    }

As side effect for every created bean a entry is created in org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator#advisedBeans This map contains the bean name and the information if this bean was proxied. In our case the responsible class was the AspectJAwareAdvisorAutoProxyCreator. After creating ~7 million prototype beans the map advisedBeans had a size of ~ 4GB.


Affects: 4.2.6

Comment From: spring-projects-issues

Juergen Hoeller commented

Why are you specifying a new unique bean name for every initializeBean call there? That's why the factory in general and those caches specifically think they're seeing a new candidate every time... Couldn't you simply specify the same bean name there, as the container itself does it for prototype beans?

Comment From: pureleeki

please. Does this issue also affect Spring aop-3.1.2?