fixed a memory leak in InMemory connector