shared_ptr and memleaks and hard timeout