> Simple set the handle to nullptr and the system will
> destroy it. Correct?
At some point in the future, probably during an allocation, a GC will
occur. If the memory being pointed to by the pointer is no longer
referenced anywhere, then it will be reclaimed. Things are more
complicated when there is a finalizer, of course.
> If it is assigned to another object through a
> second gcnew call, the first object will also be detroyed (unless
> another reference has been made to it), correct?
Nothing will be destroyed straight away in a deterministic fashion. If
you need deterministic cleanup then use the new C++/CLI destructor
semantics (i.e. C++/CLI destructors get renamed to Dispose(), and the
class implements IDispose), and allocate the object on the "stack" as a
local (it will really still be a heap-based object, but behind the
scenes Dispose() will be called automatically).
-- Barry
bern11 - 30 Apr 2006 22:59 GMT
Thanks for the reply. I don't need deterministic cleanup. It just
feels strange to not delete. (I almost wish microsoft had a gcdelete
entry with your explaination in their help system - simply because any C
programmer new to Visual Studio will be looking for it).
>>Simple set the handle to nullptr and the system will
>>destroy it. Correct?
[quoted text clipped - 16 lines]
>
> -- Barry