use slot structure for temporary memory.
fixed memory leak in unit test.