Fix the memory refresh logic bug.