fixed memory leak when using memory store