Re: Reference counting and graceful termination of an ATL singleton.
Your reference count is 5 due to a proxy optimization - when
your obect is marshaled after initially created, the proxy grabs
5 references on it right away. This way, if a new proxy needs
to be created at the same client (say in another apartment),
there will be no need to get back to the object's server to
obtain the new reference. When the client releases all of its
references, the proxy releases all 5 references on your object
in one go. In short - never count on your reference count
(pun not intended) to get the actual number of client references
for your object.
Microsoft MVP [VC], MCSD
MVP VC FAQ: http://vcfaq.mvps.org
"Sergei V" <firstname.lastname@example.org> wrote in message
Hello, the Group.
If for some reason a client of ATL COM-object terminates abnormally
the object will stay in memory until aborted.
(say, this is an out-of-proc singleton)
Is there a way to shut it down gracefully so that it will free resources
allocated at creation (in particular, these are hardware resources)?
In other words, is there a function which if called through an interface
will, say, cause reference count go down to zero as if all clients
dereference the COM-object?
Or, at least, is there a way for the client to get the object's reference
I've tried to read m_dwRef variable, but every client receives it equal 5
Am I doing something wrong?
(everything works: after last client execute ComUninitialize() the
gets the FinalRelease() executed and terminates.)
Any suggestions or links to docs are appreciated.