April 9th, 2014

What happens to my COM server-side object when clients die unexpectedly?

Suppose you have a COM server object that runs out-of-process. A client connects to the COM server and creates an object. And then the client crashes. What happens to the server object? It will get released eventually. COM periodically checks whether the clients are still alive, and it runs down interfaces from dead clients. Run-down (often spelled rundown) is a technical term used by COM to refer to cleaning up abandoned objects. Knowledge Base 171414 describes the mechanism in some detail. (There are a bunch of optimizations in play here. You can read the Knowledge Base article to learn about some of them.) The short version is that every two minutes, the COM client pings the server to say, “Hey, I’m still alive.” If the COM server doesn’t hear from the client for six minutes, then it assumes that the client is dead and runs down the objects for that client.

Therefore, if a client dies, your server object will be cleaned up between six and twelve (eight?) minutes later.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.