Sanity check when writing to memory