Hi,
Maybe dump question.
What happens when reqest scope bean reference is set in some field of
session scoped bean. Normally at the end of the request request scope
bean should be discarded by Garbage Collector.
What I deduct is that since reference to reqest scope bean exists in
session bean, request scope bean will not be discarded. However after
next request web container will create new request scope bean and old
one will be invalid. Until I save reference to new request scope bean
in session bean. Old one will be not discarded by Garbage collector
even if from web container point of view this objct is invalid.
Is this correct?
Robert
Lew - 19 Mar 2008 14:09 GMT
> Maybe dump question.
>
[quoted text clipped - 10 lines]
>
> Is this correct?
I expect not, but I'm interested in the evidence for your deduction.
Does the object hold a circular reference to the request instance?
Unless something live refers to the request, then it becomes unreachable at
the end of the servlet service() method. It should go away in an upcoming GC.
As for object X, request-lived objects ("scope" is a compile-time term;
runtime deals with lifecycles) also go away - /unless/ there's a live
reference to them somewhere else, in your case from a session-lived object.
References don't flow "upstream", so nothing keeps the request alive unless X
itself does.
R -->\
S --> X
When the "R" arrow breaks, the "S" arrow keeps X alive. No one is holding on
to R after service() exits.

Signature
Lew