Replies: 4 comments
-
we have a scope guides: https://guides.micronaut.io/latest/micronaut-scope-types.html |
Beta Was this translation helpful? Give feedback.
-
Thanks for sharing the link! I understand that there are multiple scopes types, I want to know that will Prototype and default scope beans get destroyed by Micronaut? Or I will need to explicitly call |
Beta Was this translation helpful? Give feedback.
-
you have the explicitly destroy it yourself for prototypes. There is no way for Micronaut to know when a bean is due to be destroyed |
Beta Was this translation helpful? Give feedback.
-
It is destroyed when the parent is destroyed, when you get it directly from the bean context you need to destroy it yourself |
Beta Was this translation helpful? Give feedback.
-
Issue description
Hi,
Q1: How Micronaut handles the bean lifecycle for Prototype and default scopes? Any Docs? I read these docs https://docs.micronaut.io/latest/guide/#scopes and https://docs.micronaut.io/latest/guide/#lifecycle
Q2: If a bean gets created with Prototype and default scopes, will they get garbage collected by Micronaut?
For example: a client who creates the beans by calling
ApplicationContext.getBean
orApplicationContext.createBean
, does the client have to explicitly callApplicationContext.destroyBean
to destroy the beans?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions