Perhaps this is not your case, but, for example, the Microsoft COM CComObject::CreateInstance method can return E_OUTOFMEMORY (at least in the implementation I can find in my environment, that is, Visual Studio 2012), and, in my opinion, it can mislead.
The COM method is similar to the following (in atlcom.h )
ATLPREFAST_SUPPRESS(6387) template <class Base> _Success_(return == S_OK) HRESULT WINAPI CComObject<Base>::CreateInstance( _Deref_out_ CComObject<Base>** pp) throw() {
and it seems to me that the above code can return E_OUTOFMEMORY even if you have a lot of memory available: the ATLTRY macro just ends the new call in try-catch (...), and therefore, if the Base constructor does not throw an exception, any exception will even not related to memory issues, then p will be NULL and the function will return E_OUTOFMEMORY .
source share