Suppose you run the following program:
class Program { static Class1 foo = new Class1(); static void Main(string[] args) { Class2 bar = new Class2(); Class3 baz = new Class3(); baz = null; Debugger.Break(); bar.Run(); } }
When a program breaks down into a debugger, there are 3+ objects that cannot be selected for garbage collection due to the following links:
- a
Class1 object referenced by the static field foo - a
string[] object referenced by the args parameter - zero or more
string objects referenced by the string[] object referenced by args - a
Class2 object referenced by the local variable bar
The Class3 object has the right to collect garbage and may already be collected or wait for completion.
References to global objects in C # are not allowed. References to the CPU registers are part of the implementation of the VM.
dtb
source share