fix: fix sample and prevent memory leak