fix memory reset bug