fix memory check