fix memory leak in loadMedia