ChristianLa91 / slimdx

Automatically exported from code.google.com/p/slimdx
MIT License
0 stars 0 forks source link

Direct3D 10: OpenSharedResource() Memory Leak #728

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version: June 2010 with .NET 4.0

The implementation of OpenSharedResource in Device10.cpp is not releasing the 
temporary handle from ID3D10Device::OpenSharedResource. This remains as an 
outstanding reference and prevents the shared resource from being released. I 
resolved the issue in my local copy of the source as follows:

generic<typename T> where T : ComObject
    T Device::OpenSharedResource(System::IntPtr handle)
    {
        ID3D10Resource *resultPointer;

        HRESULT hr = InternalPointer->OpenSharedResource( handle.ToPointer(), __uuidof(ID3D10Resource), (void**)(&resultPointer) );
        if( RECORD_D3D10( hr ).IsFailure )
            return T();

        MethodInfo^ method = T::typeid->GetMethod( "FromPointer", BindingFlags::Public | BindingFlags::Static );

        T result = safe_cast<T>( method->Invoke( nullptr, gcnew array<Object^> { IntPtr( resultPointer ) } ) );

        resultPointer->Release(); 

        return result;
    }

I believe this problem is in the Direct3D 11 implementation as well.

Original issue reported on code.google.com by eFea...@gmail.com on 4 Nov 2010 at 6:03

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r1713.

Original comment by josh.petrie on 15 Nov 2010 at 4:40