Registering an interface in the Global Interface Table prevents destructor from being called

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Michael Carr (mcarr_at_umich.edu)
Date: 03/01/05


Date: Tue, 1 Mar 2005 01:59:40 -0500

I am writing an apartment threaded object that needs to share interfaces
across threads. In an initialization routine I create the Global Interface
Table and register one of my interfaces in it (IConnectionPointContainer,
specifically). Now, at any point after this if I release the object from my
client app, the destructor of my object is never called -- the app just
hangs. If I revoke the interface from the GID before releasing the object,
then the destructor is called correctly. To me, it appears that the GID is
holding a reference to the interface and preventing my destructor from ever
being called...however I don't want to rely on the client to call a cleanup
method before releasing the object because this object will be used in
Access VBA which creates and releases objects somewhat arbitrarily. Any
ideas?

Thanks!!
Michael Carr



Relevant Pages

  • Re: Looking for COM class that has methods with output parameters
    ... What contradiction do you see? ... argument of IDispatch::Invoke (a COM interface). ... The calling code is responsible for releasing all strings and objects ... referred to by rgvargor placed in *pVarResult. ...
    (microsoft.public.win32.programmer.ole)
  • Re: C++ interface
    ... > destructor because they don't exist for the interface. ... > constructors, destructor and etc. ... If you can somehow be sure no derived class will have a destructor ...
    (comp.lang.cpp)
  • Re: Dispose, Dispose(true), Finalize, IDisposable
    ... the Destructor such as ... There is no extra code executed when an object goes out of scope, as there is in a system using reference counting, so there is no way that you can make anything happen when an object goes out of scope. ... There is nothing magic about the IDisposable interface, it's just an interface as any other. ... system should still have the responsibility to clean up. ...
    (microsoft.public.dotnet.general)
  • Re: Derived destructor not being called
    ... I've been working on an IDL implementention and I'm having problems ... interface IMyDerived: IMyBase { ... // I'm hoping that the destructor in CMyDerived will be called ... keep un-addref'd pointers to COM objects in containers, ...
    (microsoft.public.vc.language)
  • Re: Problem with WM asf Filter when using with Dshow.
    ... >> Could you post the function where you are releasing the interface? ... >are initiatied at various points through the graph building. ... uninitialized before all interface pointers have been released. ...
    (microsoft.public.win32.programmer.directx.video)