add sample, fix memory leak