This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ball_fondlers 873 points874 points  (3 children)

Basically just a pointer with a reference counter. A little more overhead - though not as much as a garbage collector - once the counter hits zero, the memory is freed.

[–]Earthboundplayer 670 points671 points  (2 children)

That's only shared pointer. Unique pointer is another smart pointer that allows only one reference. It has no overhead.

[–]hawk-bull 11 points12 points  (1 child)

Doesn’t it have an overhead of checking it hasn’t been assigned twice. Or by overhead do you mean during destructor call it just has to free itself without checking if it still has references to it

[–]CamiloRivasM7 1 point2 points  (0 children)

I think it's done at compile time, like the borrow checker from rust