more cleanup thread routines
fix test a little
test script for investigating runtime huge memory size