I realized that after calling vector.clear() which hold shared pointers, the destructors of the object which own by shared_ptr is not being released. <
you have two copies of shared_ptr in this case, one is the sharedptr variable and the other as an element in the vector.
do this instead
test.push_back(std::move(sharedptr));
note now the original sharedptr has it's internal moved and no longer usable. The other thing is don't do anything at all, this is a perfectly valid usage of of shared_ptr and sharedptr will clean up itself after it goes out of scope.