Spring 5.0 Cookbook
上QQ阅读APP看书,第一时间看更新

How it works...

Most of the time, developers prefer to load Singleton objects because they consume memory efficiently rather than having several Prototype objects across the platform.

When it comes to the post-processing clean up, Spring will not have a hard time managing the resources used by Singleton since the entire application uses only one bean object during its request-response transactions. In the case of Prototype beans, the container must implement a post-processor that will clean up all the garbage and some bulk of resources consumed by the series of instantiations every fetch.