の場合、DisposeメソッドでGC.SupressFinalizer()を呼び出すと、 はすべてのインスタンスメンバにnullを割り当てて、それらをクリーンアップする必要があります。 ?例えばIDisposableパターン:GC.SupressFinalizer
:
class test : IDisposable
{
public int a = 10;
public int b = 20;
public int c = 39;
private bool is_disposed = false;
Dispose(bool shall_dispose)
{
if(!is_disposed && shall_dispose)
{
is_disposed = true;
// shall I annulate a, b & c or they will be freed anyway??
// a = null; ?, integers aint nullable
// b = null; ?
// c = null; ?
// or primitive types should't be annulated? only reference(heap) types?
}
}
Dispose()
{
Dispose(true);
}
~test()
{
Dispose(false);
}
}
ありがとうございました。これは、とにかくGCが実行され、オブジェクトをクリーンアップすることを意味しますが、デストラクタ呼び出しは行われません。右 ? – Alex
正確にはどういう意味ですか –