The generic function
com-object-destructor
is called by the implementation of the class
standard-i-unknown
at the point where the last COM interface pointer is removed for the object, i.e. where the overall reference count becomes zero. After this, the object is known only to Lisp and is not involved in any COM operations and will be freed as normal by the garbage collector. The built-in primary method specializing on
standard-i-unknown
does nothing. The build-in around method specializing on
standard-i-unknown
frees the memory used by the COM interface pointers. Typically, after methods are defined to handle class-specific cleanups.
(defmethod com-object-destructor :after
((my-doc doc-impl))
(close (document-file my-doc)))