![]() |
| | #1 |
| Registered User Join Date: May 2006
Posts: 1,579
| object destroy Two questions about the following code, 1. When instance of Class1 is put to GC queue, its wrapped Obj instance is 100% ensured to move to GC queue, but the order of whether the memory and Finalize method of Class1 instance or obj1 instance will be called first can not be decided (GC may make different decision in different situations)? 2. If some instance does not hold the reference of Class1, but holds the reference to obj1 through public method PassOut, in this situation, Class1 instance is prevent from being GCed? Code: using System;
/// <summary>
/// Summary description for Class1
/// </summary>
public class Class1
{
private Component Obj = new Component();
public Component PassOut()
{
return Obj;
}
public Class1()
{
//
// TODO: Add constructor logic here
//
}
}
thanks in advance, George |
| George2 is offline |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Object destroy itself? | cminusminus | C++ Programming | 28 | 03-27-2008 01:08 AM |
| using this as synchronization object | George2 | C# Programming | 0 | 03-22-2008 07:49 AM |
| circular doubly linked list help | gunnerz | C++ Programming | 5 | 04-28-2007 08:38 PM |
| Question on l-values. | Hulag | C++ Programming | 6 | 10-13-2005 04:33 PM |
| A question about constructors... | Wolve | C++ Programming | 9 | 05-04-2005 04:24 PM |