fix memory to work with new API