How can I see what references are keeping my ref objects from being deleted in c++/cx?

时光总嘲笑我的痴心妄想 提交于 2019-12-12 22:25:21

问题


I use myclass^ in one place in my UWP project, but I suspected that they weren't actually being deleted when they went out of scope. So I made a destructor that called __debugbreak() for myclass^ to make sure that was getting called. Instead of the 40 calls I should be getting for my project, I got one. To my understanding, types with hats (^) are basically shared_ptrs so if my object isn't getting deleted, it's probably because something else in the project holds a reference to it. How can I diagnose this and see what other references to the object there are in Visual Studio?


回答1:


How can I diagnose this and see what other references to the object there are in Visual Studio?

You could diagnose this with Memory Usage Tool in Visual Studio. For detail steps, you could refer Diagnosing memory issues with the new Memory Usage Tool in Visual Studio. And you could take snapshot in order to capture the state of the application memory.

When you select a type or an instance, you could see its references, this is the primary view that you will be using to understand why certain types or instances are not being collected during a garbage collection run.



来源:https://stackoverflow.com/questions/48106743/how-can-i-see-what-references-are-keeping-my-ref-objects-from-being-deleted-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!