Re: More on garbage collection



David Gay <dgay@xxxxxxxxxxxxxxxxxxxxx> writes:

> torbenm@xxxxxxxxxxxxx (Torben Ægidius Mogensen) writes:
> > David Gay <dgay@xxxxxxxxxxxxxxxxxxxxx> writes:
> > > If you have to invoke a destructor, I'm not sure where automatic
> > > garbage collection enters the discussion.
> >
> > The garbage collector can invoke the destructor on
> > no-longer-referenced objects before they are (automatically)
> > deallocated.
>
> That doesn't work if the object references itself (a cycle), at which
> point a reference-counted garbage collector will not know it should
> invoke the destructor.

You wouldn't use reference counting for GC if you have cyclic
structures anyway. The main potential problem is that the order in
which destructors are invoked is unspecified, so you would probably
want destructors to only access local fields (i.e., not follow
pointers to other objects).

Torben
.



Relevant Pages

  • Re: More on garbage collection
    ... >> If you have to invoke a destructor, ... point a reference-counted garbage collector will not know it should ...
    (comp.arch)
  • Re: delete in-place corresponding to placement new?
    ... > that comes to mind is to merely explicitly invoke the destructor. ... > capability is not available on a circa 1990 compiler. ... static void destroy(T *ptr) ...
    (comp.lang.cpp)
  • Re: Access Violation Releasing CComPtr
    ... You're using COM objects from DllMain (global destructors are ... TerminateProcess) which doesn't invoke ... msxml3.dll!DOMDocumentWrapper::`vector deleting destructor'() + ... hDllHandle=0x0dea0000, unsigned long dwReason=0x00000000, void * ...
    (microsoft.public.platformsdk.security)
  • Re: delete []
    ... when invoke delete, the destructor for each instance element of the ... , I malloc 10 bytes, and in the destructor of this class I will ... So the memory is balanced, ...
    (microsoft.public.dotnet.languages.vc)
  • derived method of abstract base class not getting invoked
    ... Code to invoke: ... saying there is no source code available. ... Since this is debug compiled code I assume the compiler is responsible ... I should add that I had the same problem with the base destructor, ...
    (microsoft.public.vc.language)