Regarding the scope and garbage collection in Spring bean container

后端 未结 2 1628
轻奢々
轻奢々 2021-02-07 07:16

I am new to Spring and I am currently using it in one of my projects. I learned that the Spring container holds all the beans and the scope of all the beans is \"singleton

2条回答
  •  -上瘾入骨i
    2021-02-07 07:48

    The container doesn't keep a reference to instantiated beans, the code that's using them does.

    If nothing else references the bean (roughly), it's eligible for GC.

提交回复
热议问题