Hi, I'm experiencing some unexpected behavior with a Vec<Arc> and would really appreciate it if someone could help me fill in the gaps. When I allocate a Vec, iteratively push some large number of Arc elements to it, then drop everything, the Arcs (apparently) have a strong reference count of 0, but do not free their memory.
A minimal example is in this playground link. massif and heaptrack both show a heap size of (effectively) 0 after
mk_arcs() scope ends, but htop says it's still consuming ~4% of 8 Gb while it stalls at the end. Trying to run the process iteratively bricks a VM after exhausting all of the memory, so I think htop is correct. I'm not using any custom allocators. Removing the weak reference in the playground link doesn't change the behavior.
My reading of the drop procedures for Vec and Arc are that the Vec should drop, iteratively calling drop on all its elements, which would decrement the strong_count to 0 on each arc, therefore dropping the arc + its contents and freeing the memory it was using.
weak_canary in the playground link does indicate that the Arc elements have a strong_count of 0 by the time
mk_arcs() scope ends.
Thanks for any help