Where does the destructor code for things I have defined in an ATL COM object belong?
Should it go in ~MyComClass() or in MyComClass::FinalRelease()?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As long as
FinalReleaseis in question, I assume your question is related to ATL.In most cases you can clean things up in either of the two.
FinalReleasewill be called immediately before the actual destructor. The important difference is that if you aggregate other objects, FinalRelease gives you a chance to clean the references and release dependencies before actual destructor of top level COM object class (esp.CComObject) starts working.That is, you clean things up in two steps, first references to aggregated objects in
FinalReleaseand then other things in eitherFinalReleaseor destructor.