After enabling @Autowrid
, Maven project with Spring 4, in approximately: 800 ManegedBeans Spring, 900 Services, 1000 @Component
and 1000 @Repository
, the startup application trhow an OutOfMemoryError
.
I increased the parameters -Xms1024m -Xmx4g
in Tomcat and Wildfly, in the application I added the default-lazy-init = "false"
parameter in applicationContext.xml
and at a great cost the application is starting. I would like to know if there is any advantage in removing
@Autowired
private AnyService anyService;
from all classes and use
public void execute() {
AnyService anyService = (AnyService)applicationContext.getBean(AnyService.class);
anyService.execute();
}
within the methods. Does using the local variable instead of the instance can optimize the startup? Brings some benefit to the GC? The call applicationContext.getBean(AnyService.class) may worsen performance of methods?