Spring bean destroy-method , singleton and prototype scopes

后端 未结 6 1336
暗喜
暗喜 2020-12-31 00:34

I am new to the spring framework, started with some tutorials to learn it.

I have following files,

# MainProgram.java

package test.spring;
im         


        
6条回答
  •  攒了一身酷
    2020-12-31 01:07

    your application could ask for new instances of prototype beans every 10 milliseconds, do something with the bean, and then let it go out of scope. If Spring had to destroy() them when the application shuts down, it would have to keep a reference to every created prototype bean, preventing them to be garbage-collected, and thus causing a memory leak.

提交回复
热议问题