fixed memory leak in capture