From examples I've seen COM IUnknown::Release() function implementation is something like that:
ULONG Release()
{
    InterlockedDecrement(&m_count);
    if(m_count == 0) {
       delete this;
    }
    return m_count;
}
So, if m_count is 0, so we're deleting "this" object, and returning the ref count. What I don't understand is why it works ?!?!
- Deleting the object wouldn't ruin the call stack or is it okay because it is being held by the thread, so it has nothing to do with the object ??? 
- If the object has been deleted, how is it possible that we can return m_count, it should've been deleted. I could have convinced myself that it's okay if after the delete the code would return hard-coded 0, but how come it can return the member ?!?! 
Thanks a lot for your help! :-)
 
     
     
    