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. <
vector.clear()
shared_ptr
Here sharedptr and the element in vector share the same object which will result in invoking constructor and destructor only once.