When you use shared pointers what is the mechanism that releases the memory from the shared pointer itself

Viewed 97

I understand that shared pointers work by counting references and releasing the object the pointer is pointing to. But the shared pointer takes space itself, is it released somehow? is there a pool of shared pointers and they are reused? is this something easy to track in the library source code?.

1 Answers

The place where you store the shared pointer is up to you, the same way any other variable.

For instance, if you have it as a local variable in a function, then it will likely be held in the stack.

Related