dimanche 24 juillet 2016

Tracking down owner of a shared_ptr?

In our app we're about to (finally..) switch from raw pointers to using C++11 smart_ptr templates.

We do have the occasional bug in our app with (non C++) objects still keeping references to our C++ objects causing crashes in the past when accessing the then-dealloc'd objects.

Not sure if this is a silly question - but is there a way to take advantage of the smart_ptr objects and 'dump' the objects still holding on to the C++ objects when none are expected to hold a reference to one any more?

I guess what I'm asking for is a way to list all owners of smart_ptr<MyClass> at a certain point in time.

Any suggestions much appreciated!

Aucun commentaire:

Enregistrer un commentaire