P
Peteroid
A few questions regarding delete and garbage collection (gc).
First, is something not ordinarily gc which is created via new in a garbage
collected class also garbage collected? That is:
__gc myGCClassA
{
public:
myGCClassA()
{
m_String = new char[100] ;
}
~myGCClassA()
{
delete [] m_String ; // ***is this necessary to free memory? if
not, is it ok? ***
}
private:
char* m_String ;
} ;
Second, is it ok to delete something 'pre-maturely' in a gc class? That is,
__gc myGCClassB
{
public:
myGCClassB()
{
m_A = new myGCClassA() ;
}
~myGCClassB() {} ;
void FreeA()
{
delete m_A ; // *** is this ok to do? ***
}
private:
myGCClassA* m_A ;
} ;
Next, is it true that a GC instance created in a non-gc class WILL gc itself
anyway?
Finally, when a gc class instance is destroyed for any reason or deleted,
does it still execute the destructor?
Thanx! : )
[==Peter==]
First, is something not ordinarily gc which is created via new in a garbage
collected class also garbage collected? That is:
__gc myGCClassA
{
public:
myGCClassA()
{
m_String = new char[100] ;
}
~myGCClassA()
{
delete [] m_String ; // ***is this necessary to free memory? if
not, is it ok? ***
}
private:
char* m_String ;
} ;
Second, is it ok to delete something 'pre-maturely' in a gc class? That is,
__gc myGCClassB
{
public:
myGCClassB()
{
m_A = new myGCClassA() ;
}
~myGCClassB() {} ;
void FreeA()
{
delete m_A ; // *** is this ok to do? ***
}
private:
myGCClassA* m_A ;
} ;
Next, is it true that a GC instance created in a non-gc class WILL gc itself
anyway?
Finally, when a gc class instance is destroyed for any reason or deleted,
does it still execute the destructor?
Thanx! : )
[==Peter==]