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
정확히 무엇을 의미합니까? –