0

I have a test that shows memory leak in my app:

enter image description here

RAM usage increases 30-40MB per iteration, the profiler shows it’s in external code.

Between the iterations, I shut down & then recreate D3D device. When I stopped doing that and just kept the device alive, it became good:

enter image description here

The only difference is 2 interface pointers: ID3D11Device, and IMFDXGIDeviceManager.

Is there a way to shutdown a D3D device so it releases the memory instead of leaking?

As far as I understand, if I would have leaked a resource pointer somewhere, it would continue leaking with an old device. Does it mean the problem is in Windows 10, not in my code? For now, I obviously keeping the device alive, but ideally I’d like a way to implement clean shutdown.

Soonts
  • 20,079
  • 9
  • 57
  • 130
  • You can use ``Release`` method to free that device – Asesh Sep 27 '18 at 03:45
  • @Asesh I’m calling `Release`, but the memory still leaks. – Soonts Sep 27 '18 at 03:58
  • Did you check the reference count? If you are using debug version then it should display what device is leaking that memory in the VS output window – Asesh Sep 27 '18 at 03:59
  • Forgot to mention, you must have created that device with ``D3D11_CREATE_DEVICE_DEBUG`` when calling ``D3D11CreateDeviceAndSwapChain`` – Asesh Sep 27 '18 at 04:11
  • @Asesh No, not checking, I’m just using `CComPtr<>`. Good idea, will try that later. – Soonts Sep 27 '18 at 04:18
  • 2
    Use Direct3D and DXGI object tracking. See [this blog post](https://blogs.msdn.microsoft.com/chuckw/2012/11/30/direct3d-sdk-debug-layer-tricks/) and [this one](https://blogs.msdn.microsoft.com/chuckw/2015/07/27/dxgi-debug-device/). – Chuck Walbourn Sep 27 '18 at 07:06

0 Answers0