valgrind check, free thread memory