Fix memory leak of ResourceObjects