I came to know that smart pointer is used for resource management and supports RAII.
But what are the corner cases in which smart pointer doesn’t seem smart and things to be kept in mind while using it ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Smart pointers don’t help against loops in graph-like structures.
For example, object A holds a smart pointer to object B and object B – back to object A. If you release all pointers to both A and B before disconnection A from B (or B from A) both A and B will hold each other and form a happy memory leak.
Garbage collection could help against that – it could see that both object are unreachable and free them.