P
puzzlecracker
A cut-and-paste from the Jon's book, with a question to follow:
Utter garbage! (Or not, as the case may be…)—It’s worth being aware
that a
delegate instance will prevent its target from being garbage
collected, if
the delegate instance itself can’t be collected. This can result in
apparent
memory leaks, particularly when a “short-lived” object subscribes to
an event in a “long-lived” object, using itself as the target. The
long-lived
object indirectly holds a reference to the short-lived one, prolonging
its lifetime
1) what does target refer to (delegate instance will prevent its
target from being garbage)?
Utter garbage! (Or not, as the case may be…)—It’s worth being aware
that a
delegate instance will prevent its target from being garbage
collected, if
the delegate instance itself can’t be collected. This can result in
apparent
memory leaks, particularly when a “short-lived” object subscribes to
an event in a “long-lived” object, using itself as the target. The
long-lived
object indirectly holds a reference to the short-lived one, prolonging
its lifetime
1) what does target refer to (delegate instance will prevent its
target from being garbage)?