简体   繁体   中英

D3D leaks, but is it because I have references in global objects?

I am getting device leak reports (and a non-zero ref count dialog) from the D3D11 debug runtime. I have two global classes that contain smart pointers to the layout buffer, vertex shader, and pixel shaders.

If I place a breakpoint on the destructor of those classes, I can see the leak reports happen before those globals are even deleted, perhaps as you might expect.

What's the right way to correct this, while still keeping those global (for now)? I was planning to add a 'cleanup' function that releases everything manually during shutdown rather than relying on the smart pointers, but that feels like a bit of a hack.

Yeah this is a bit annoying. Traditionally I document then ignore these false positives. But if you want to work around it, resetting the smart pointers at the bottom of main will probably do the job.

Y'know, unless other objects with static storage duration rely on those classes. They don't, right??

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM