Fix memory leak on linux