J
joe.carr
Hello,
A discussion arose recently in a code review about whether or not one
should implement IDisposible (and then call it) on an object which has
neither unmanaged resources nor managed resources which are resource
intensive (db connections, filestreams, etc.). It seems to me that if
you do not have such items to explicitly dispose yourself, then it is
best to let the Garbage Collector do its work when it determines it is
the best time to clean up these objects.
But, my question is, does it matter? If I have SimpleObject, and I
call simpleObject.Dispose() when I'm done with it, is there an
associated performance liability over not calling the method?
Also, if I write an empty Dispose() method :
public void Dispose()
{
}
Is this object removed from the managed heap when I call that method?
Or is it actually cleaned up on Finalization, because it does not
suppress Finalization?
Thanks beforehand for any information.
A discussion arose recently in a code review about whether or not one
should implement IDisposible (and then call it) on an object which has
neither unmanaged resources nor managed resources which are resource
intensive (db connections, filestreams, etc.). It seems to me that if
you do not have such items to explicitly dispose yourself, then it is
best to let the Garbage Collector do its work when it determines it is
the best time to clean up these objects.
But, my question is, does it matter? If I have SimpleObject, and I
call simpleObject.Dispose() when I'm done with it, is there an
associated performance liability over not calling the method?
Also, if I write an empty Dispose() method :
public void Dispose()
{
}
Is this object removed from the managed heap when I call that method?
Or is it actually cleaned up on Finalization, because it does not
suppress Finalization?
Thanks beforehand for any information.