Raise exception if invalid memory specification