You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd propose disposable structs in order to avoid memory leaks due to undisposed unmanaged objects.
The structs
ComPtr
ComHeapPtr
Usage
{try{usingComPtr<T1>pObj1=default;varhr=CoCreateInstance(...,(void**)pObj1.GetAddressOf());varhr=pObj1.Get()->Method1(...);usingComHeapPtr<LPWSTR>pDisplayName=default;}catch(Exceptionex){// Log the exception}}
Concerned code
All com related unmanaged objects.
Gains
prevent memory leaks
Requirements
Implement the structs that implements IDisposable and use it through 'using' statement
Comments
No response
The text was updated successfully, but these errors were encountered:
0x5bfa
changed the title
Code Quality: Dispose COM pointers automatically using IDisposable
Code Quality: Dispose unmanaged objects automatically using IDisposable
Sep 25, 2024
Description
I'd propose disposable structs in order to avoid memory leaks due to undisposed unmanaged objects.
The structs
Usage
Concerned code
Gains
Requirements
Comments
No response
The text was updated successfully, but these errors were encountered: