I am using a piece of code like this: CDOCSObject * pObject = NULL; map<CString, CDOCSObjectCacheItem *>::iterator cacheItr = m_DOCSObjectCache.find(strID); if ( cacheItr != m_DOCSObjectCache.end() ) { pObject = (*cacheItr).second->m_pObject; pObject->AddRef(); } return pObject; pObject->AddRef() is throwing an access violation error in release builds. I tried to validate pObject using if(pObject != NULL) and IsBadReadPtr() etc but doesnt help. It still throws same error in release build. Is there a way to check for validity of COM pointer in release build. Thanks in advance Chandan