Question about ComPtr

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
MrGodin
Posts: 721
Joined: November 30th, 2013, 7:40 pm
Location: Merville, British Columbia Canada

Question about ComPtr

Post by MrGodin » March 30th, 2017, 4:03 am

Hey guys, I'm using ComPtr in a project and when i close it i get these, 19 in total
DXGI WARNING: Live Producer at 0x000001B5F56B7598, Refcount: 4. [ STATE_CREATION WARNING #0: ]
I've researched it and some are suggesting that they are not being released properly.. I can't for the life of me figure out why.
The class that uses them is being derived by another class ie: Graphics class inherits D3D11Class. D3D11Class which owns the ComPtrs, has a virtual dtor and is being called.
Any suggestion ??.
I've used the very same classes, used in the same way in another app and don't get these ?.
Peace
Curiosity killed the cat, satisfaction brought him back

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Question about ComPtr

Post by albinopapa » March 30th, 2017, 7:19 am

Man, I've run into this a while back and for the life of me I can't remember what the issue was. I remember a few trouble shooting steps like instead of passing the ComPtr's around, just return the pointers they hold, that way the ref counts don't ever fluctuate...of course this isn't as thread safe I'm guessing, but if you aren't doing any multi-threading then no biggie.

Another thing I think was make sure they are being released in the correct order. Make sure the ID3DDevice is the first to be initialized and the last to be released.

If none of that helps, I don't have a clue anymore.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Question about ComPtr

Post by chili » March 30th, 2017, 7:54 am

The problem I noticed you having before papa was not realizing that the &addressof operator was overloaded to call Release(), but that wouldn't be the problem here.

When passing com pointers (or shared pointers for that matter), you really gotta be conscious and careful about what you're doing. Like papa says, returning the managed address is a decent plan, or returning a ref to the com ptr works too. Know what you're doing and why when you use value semantics with smart pointers (tho it still should balance out in the end).
Chili

MrGodin
Posts: 721
Joined: November 30th, 2013, 7:40 pm
Location: Merville, British Columbia Canada

Re: Question about ComPtr

Post by MrGodin » March 30th, 2017, 1:58 pm

Well ... a duh moment, I wasn't releasing a couple of ID3D11Buffer objects, (feeling stupid, yet again ) O.o
Curiosity killed the cat, satisfaction brought him back

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Question about ComPtr

Post by albinopapa » March 30th, 2017, 10:56 pm

Were they not wrapped in ComPtrs?
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

MrGodin
Posts: 721
Joined: November 30th, 2013, 7:40 pm
Location: Merville, British Columbia Canada

Re: Question about ComPtr

Post by MrGodin » March 31st, 2017, 2:12 am

No there were not, figured it was ComPtr because i never gotten that message before, mind you, I am using 2017 now.
I am fiddle farting around with creating Voxel terrains with cubes. Kinda interesting.
Curiosity killed the cat, satisfaction brought him back

MrGodin
Posts: 721
Joined: November 30th, 2013, 7:40 pm
Location: Merville, British Columbia Canada

Re: Question about ComPtr

Post by MrGodin » March 31st, 2017, 2:21 am

Just a thought .. have you ever tried to write the contents of a D3D11Buffer to file ?, or is it even possible.. hmmm haha I might try that :P
Curiosity killed the cat, satisfaction brought him back

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Question about ComPtr

Post by albinopapa » March 31st, 2017, 2:36 am

Isn't it just filled with the contents you provide? Like vertices or other data?
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Post Reply