A way to explicitly break references to an instance of a class #95037
Replies: 2 comments 13 replies
-
So you expect this API to walk the entire heap and all the thread stacks to find all possible references to the given object and then set them to null? Aside from that this would break invariants/expectations, would induce race conditions (e.g. given |
Beta Was this translation helpful? Give feedback.
-
Are you looking for something like a weak reference? |
Beta Was this translation helpful? Give feedback.
-
I know that the first thought on this will be 'C# uses automatic memory management' and whatnot, but my proposal is an addition to such a system, not an interference of, but a way to 'manually' break references to an instance leaving it unreachable and thus eligible for collection by GC, this wouldn't force collection, or even indicate to GC that it should be collected, it would only make that instance eligible for it, at which point GC will collect when it gets to it.
Beta Was this translation helpful? Give feedback.
All reactions