Sorry for wrong information of the refcount. but It's not important how many refcount is increasing by CreateVisual. The weird thing is you have to create and release target before releasing device. even if you don't need own target object for the device object.
Bugs in Direct-composition
RSJ
1
Reputation point
- Reference count in "IDCompositionVisual3" unexpectedly get increased by one with "DCompositionAttachMouseDragToHwnd". And It never get released automatically from anywhere. so currently i release the refcount manually after when i called "DCompositionAttachMouseDragToHwnd".
- Can not release instance of "IDCompositionDesktopDevice" properly without instance of "IDCompositionTarget". IDCompositionDesktopDevice::CreateVisual increases refcount by 2 in IDCompositionDesktopDevice object. And You may not release this object properly unless you have an instance of "IDCompositionTarget" created by that device object, And you have to release it before releasing IDCompositionDesktopDevice. You know you might not need a target for a device. and neither did i. But now i have realized i have to create a "target" object to release device object even if i don't need it.
Windows development | Windows API - Win32
2 answers
Sort by: Most helpful
-
Xiaopo Yang - MSFT 12,736 Reputation points Microsoft External Staff
2021-07-05T07:25:23.26+00:00 Q1:
DCompositionAttachMouseDragToHwnddoes increase refcount by 1. So It's needed to release manually.
Q2: With testing the Return Value OfReleaseonIDCompositionDesktopDeviceandIDCompositionVisual2, I found IDCompositionDesktopDevice::CreateVisual increases refcount by 1 inIDCompositionDesktopDeviceobject. Perhaps your Code somewhere capture extra the reference count 1.