fix memory leak in create_mesh