I've been enjoying Oliver Sacks's "Uncle Tungsten: memories of a chemical boyhood" over the last few days and was struck by his mention of his brother Michael who knew Dickens's novels "Nicholas Nickleby" and "David Copperfield" by heart.

Without downplaying this incredible feat of memory, I was more interested in the term "by heart". Where does this phrase come from?