fixed trivial memory leak in generateInThread