Keep memory allocated per thread instead of alloc/free each time