Hi,The beandifinition scanned by componentscan should not be placed in the configurationClasses container, because the loadBeanDefinitions method does not do any processing for this part of the data.
Comment From: Evanhelovex
The Title Means ConfigurationClasses has userless data
Comment From: snicoll
@Evanhelovex I am not sure what you're trying to report here. A bug? A suggestion of improvements? Please clarify the intent.
Comment From: Evanhelovex
Sorry about this,It is A suggestion of improvements. I think the Beandifinition scanned by @Component Scan can be removed from configurationClasses which saves some memory.
Comment From: snicoll
Can you please share a benchmark that shows concretely what you're describing? Thanks!
Comment From: Evanhelovex
org.springframework.context.annotation.ConfigurationClassParser#processConfigurationClass before fixing:this.configurationClasses.put(configClass, configClass); after fixing: if(configClass.isImported()){ this.configurationClasses.put(configClass, configClass); }
Comment From: Evanhelovex
Could you understand what i am describing
Comment From: Evanhelovex
I mean that BeanDefination scaned by the @compoentScan is already been registered in the beanDefinitionRegistry before added to the configurationclass.
Comment From: snicoll
@Evanhelovex I am afraid I don't and this doesn't help me to I am afraid. This is also the reason why I am asking for a benchmark since you're claiming that it would save memory and we need to validate that before considering any change.
Comment From: Evanhelovex
Regarding the problem of memory overflow, I have tested many times, and it does not happen, because the configClasses container stores metadata information. However, I still think that the beans scanned by @componentScan should not be put into the container, because no subsequent processing is done, which will lead to misleading understanding. For example, when I am thinking about why the beans scanned by componentScan are put into the container, loadBeanDefinitions does not handle these beans. These beans are already placed in the Spring container in the scan method(#doScan).
Comment From: wxasacoder
I am tested this too, Although the size of metadata is pretty small,useless elements should not be put in the container at any time.
Comment From: snicoll
@Evanhelovex I am going to close this now as there is no concrete information that you've provided that makes me think there is a problem and I can't justify spending time figuring out based on the code snippet you've shared.
Comment From: Evanhelovex
Well, Stéphane,I'm in a serious attitude, let's explain it with screenshots, it won't break the existing functions through my modification, and it's helpful to read the source code, (org.springframework.context.annotation.ConfigurationClassParser#processConfigurationClass)