PC Review


Reply
Thread Tools Rate Thread

reference type garbage collection

 
 
=?Utf-8?B?SXZhbg==?=
Guest
Posts: n/a
 
      7th Apr 2006
If a reference to an object or an array is set to null, will the object/array
and all of it’s members/elements be garbage collected as well (Assuming that
no other references are held on the members/elements, and none of these
members/elements hold references to unmanaged resources.)?

For example:

public class A
{
public A(){}
}
..
..
..
A[] A_array = new A[5];

for(int i = 0; i < 5; i++)
{
A_array[i] = new A();
}

A_array = null; // Will all of A_array’s elements be garbage collected here?


thanks
 
Reply With Quote
 
 
 
 
Joanna Carter [TeamB]
Guest
Posts: n/a
 
      7th Apr 2006
"Ivan" <(E-Mail Removed)> a écrit dans le message de news:
3F639DBA-F90E-402C-9165-(E-Mail Removed)...

| If a reference to an object or an array is set to null, will the
object/array
| and all of it's members/elements be garbage collected as well (Assuming
that
| no other references are held on the members/elements, and none of these
| members/elements hold references to unmanaged resources.)?

Strictly, when an object reference is nulled, assuming no other references
exist, the object becomes available for GC but there is no guarantee when
the GC will occur. In practice, it could be fairly immediate but ...

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen Microsoft ASP .NET 1 18th May 2007 10:24 AM
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen Microsoft Dot NET 1 18th May 2007 10:24 AM
Circular reference and Garbage collection Guogang Microsoft C# .NET 1 5th Sep 2003 06:38 PM
.NET: garbage collection for data type returrned from COM Interop JC Microsoft Dot NET 1 8th Jul 2003 09:33 PM
.NET: garbage collection for data type returrned from COM Interop JC Microsoft C# .NET 1 8th Jul 2003 09:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:13 PM.