In other words, how does the implementation keeps track of the count?
Is there a map-like object maintained which is accessible by all the shared_ptr
instances whose key is the pointer's address and value is the number of references? If I've to implement a shared_ptr
, this is the first idea that's coming to my mind.
Is there a possibility for a memory leak in case of these reference-counting smart pointers? If so, how can I avoid them?
See Question&Answers more detail:os