what keeps a COM object alive?

finalpatch fengli at gmail.com
Tue Jun 11 20:38:04 PDT 2013


A typical COM server would create a new object (derived from 
IUnknown), return it to the caller (potentially written in other 
languages). Because the object pointer now resides outside of D's 
managed heap, does that mean the object will be destroyed when 
the GC runs? A normal COM object written in C++ relies on 
reference counting to manage its life cycle but in D the ref 
counting seems not serving any purpose. The AddRef()/Release() of 
std.c.windows.com.ComObject maintains a ref count, but doesn't 
really use it for any thing. There's a comment in Release() says 
"let the GC reap it", but how does the GC know the object is okay 
to destroy?


More information about the Digitalmars-d-learn mailing list