Hi, just a quick question.
c#
voidf myf()
{
ResultBuffer pRb = new ResultBuffer();
blabla....
pRb must be disposed() ?
}
Technically, no it doesn't have to be disposed.
It can be, and probably should be especially if
it's large, but if you don't do it, the unmanaged
resources (the resbuf chain) is deleted when the
instance is finalized by the GC.
Since everything that can appear in a ResultBuffer
is thread-safe, there's no danger from allowing it
to be finalized.
The same holds true for many other objects in the
managed api (like for example, ObjectIdCollection).
The unmanaged data they delete when they're
disposed can be deleted in any thread, so there's
no problem with allowing them to be finalized.
The reason why so many managed API objects that
do not have to be determinstically disposed implement
IDisposable, is largely one of convenience (and in my
opinion, crappy API design), by virtue of their common
ancestor (DisposableWrapper).