Re: COM object not being released if it created other objects internally...
kombat <ohadpr@gmail.com> wrote:
what would you suggest for a situation where I have an ATL EXE Server
that hosts my singleton manager object.
this manager is used by many dlls in parallel, and it's crucial that a
only a single instance of it is made, and that this instance is the
one used by all the other dlls.
The COM object itself doesn't need to be a singleton. You can have a
regular C++ singleton internally that does the real work, and multiple
COM objects that simply forward calls to it. Each client would create
its own COM objects, but these objects are just thin shims on top of a
singleton manager object (which does not need to be COM-aware or
directly exposed over COM).
This solves lifetime issues nicely. Each shim object lives as long as
the client keeps references on it, as is usual with COM. The singleton
lives as long as at least one shim is alive, or you may choose to make
it live as long as the application is running.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925