0

I have an application that creates a device, draws stuff and can be closed, while not exiting the application.

In case of closing a window I want to dispose all d3d objects that belong to the device, as well as removing the device object. Completely freeing the memory for this window. If a new window is opened after within the still running app I want a new device and all objects and stuff.

This works well, besides the memory being freed part.

I dispose all the objects and at the end I call dispose on the ImmediateContext and on the device.

            mDevice.ImmediateContext.ClearState();
            mDevice.ImmediateContext.Flush();
            mDevice.ImmediateContext.TryDispose();
            mDevice.TryDispose();

If I debug my application and check this:

Device.QueryInterface<DeviceDebug().ReportLiveDeviceObjects(ReportingLevel.Detail) 

I get following result: enter image description here

As you can see all but the device are IntRef.

At this point with deleted window and in the state about to open a new one I expect the memory to be freed now. But this is not the case... Nothing is beeing released even though the references are gone.

If I exit the application after that, I get no warnings about still active objects.

I wonder if this is because of the device references? But I surely dispose the device. I am not sure what this 3 in the pic says to me and if I have to handle something there.

The memory stays up and nothing at all seems to be freed.

Thanks for any help in advance!

(I am still new to developing with DirectX)

5
  • 1
    COM interfaces have Release method which decrements the reference count and frees the associated memory. Those Direct3D APIs inherit from IUnknown interface so you should call that method. Not sure how sharpdx handles those APIs
    – Asesh
    Jan 17, 2018 at 14:29
  • By calling .Dispose() on these objects. Jan 17, 2018 at 15:57
  • You should ask this question on: gamedev.stackexchange.com I haven't used C# APIs for graphics programming so I know less
    – Asesh
    Jan 17, 2018 at 16:03
  • Do you get your screenshot after disposing of the device? If so, you are leaking devices. Even if you are, as I noted in your other question, my experience is that graphics drivers allocate memory and dispose it independently of the Direct3D objects you have allocated.
    – NextInLine
    Jan 17, 2018 at 19:55
  • I did the screenshot before disposing the device because I need a device to call "mDevice.QueryInterface<DeviceDebug().ReportLiveDeviceObjects(ReportingLevel.Detail) " Jan 18, 2018 at 7:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.