fix memory leak in surface matching module