Fix sharedMemory leak issue