Groups | Blog | Home
all groups > c# > february 2004 >

c# : Garbage Collector


Richard A. Lowe
2/29/2004 4:15:06 PM
No even assuming a more 'real-world' sample than the one you've given here..
The GC will mark all CLR-managed objects for collection that don't have a
'live' reference (reference that is still accessible in all stack frames of
currently running code). You don't have to do any manual work null-ing them
out.

Richard

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
[quoted text, click to view]

Richard A. Lowe
2/29/2004 6:34:08 PM
I probably should have said "in any stack frame" .. .but you get the idea.

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
[quoted text, click to view]

C# Learner
2/29/2004 9:58:16 PM
This is probably a silly question but I'll ask to be sure.

Say I have a constructor that looks like this:

public MyClass()
{
items = new string[10];
for (int i = 0; i < items.Length; ++i) {
items[i] = new String();
}
}

Is the following then necessary?

~MyClass()
{
for (int i = 0; i < items.Length; ++i) {
items[i] = null;
}
C# Learner
2/29/2004 11:16:03 PM
[quoted text, click to view]

AddThis Social Bookmark Button