Releasing resources

Help
2004-11-05
2012-12-07
  • Hi, Igor.
    I'm trying to reuse your code in my app, but I don't know how to release resources properly:

    // A simple IInArchive
    NArchive::N7z::CHandler *temp = new NArchive::N7z::CHandler;
    CMyComPtr<IInArchive> archive = (IInArchive *) temp;

    // Any of these gives an access violation
    archive->Release();
    delete temp;

    How am I supposed to release all associated memory?

     
    • Igor Pavlov
      Igor Pavlov
      2004-11-06

      archive.Release();

      CMyComPtr also can release it in destructor, so in most cases you don't need to care about releasing.