clear memory after each plot, prevent memory leak