JSR-250 lifecycle annotations: Annotation Type PreDestroy

143 views Asked by At

Is the method @PreDestroy of a prototype bean called when the bean is garbage collected ?

1

There are 1 answers

0
rptmat57 On BEST ANSWER

No, it is not called when the bean is garbage collected but for the bean to be garbage collected it has to be dereferenced first, which would mean it would have to be destroyed and @PreDestroy be called.

So the method won't be called directly but it has to have been called before being garbage collected