So, I'm curious if GC - and especially finalization - will occur in an instance xin .NET when:
x does not refer to anythingx has a static property DbConnectiony is an instance of the same class as xy still referring to something
It seems to me that in this case it xcan be declared dead by external links, but the completion of it can lead to the fact that it DbConnectionwill be deleted while yit still needs and contains a link to it.
So, what is this, in the scenario I described, assembled x? Does it end? Or all instances of this type need an orphan in a heap before any of them are collected? Will there be a completion on each instance?
I would have thought so, should the general rule be followed: Never touch a static or other common object in your finalizers?
source
share