Does setting the object to null make it MARKED for GC?
EDIT: A class has got multiple static methods. when using these methods in your program, what is the best way to ensure the objects are marked for GC after a certain point?
Methods aren't garbage collected at all - so it's not really clear what your question means.
Likewise you never set an object to null. You can make the value of a variable null, but that doesn't nothing to any object that the variable previously referred to. It just means that next time the garbage collector looks for live object, that variable won't contribute any object to the set of objects which must be kept alive at the end of the GC.
I suggest you read Jeffrey Richter's article on garbage collection for a bit more background, then ask any further specific questions when you've got to grips with the basics.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With