Optimization to GetMemory/SetMemory