Natural selection encodes adaptive responses to the environment in DNA (and other molecules), so memories can be encoded to the extent that they are adaptive and can be encoded (i.e., mechanisms may not exist to encode everything using only standing natural variation).