My answer to a question on Quora: Do physicists or mathematicians actually memorize hundreds of equations?
Some (I think rare) mathematicians have excellent memory and can remember a lot of stuff. Most of them, however, do not memorise every equation / theorem / definition; they keep in their heads generalised — but well structured —images of their fields and can recover a necessary fact or definition frоm “first principles”. Mathematics is not a sum of facts, it is a system of connections between facts and connections between connections, a system of analogies, and, at a higher level of thinking, analogies between analogies.
Added later: Perhaps I have to emphasise one point: “recovery” (as opposed to “remembering”) is fast because it is frequently used in its incomplete form, something like that “ah yes, and here we shall use this and that theorem…” without recalling the exact formulation of the theorem — and then immediately moving further in the argument. Why this is done? Because in most cases a specific argument will fail at later stages anyway; filling in all details in all intermediate steps is waste of time. Details are filled in only when the logical skeleton of a proof starts to look feasible. In many cases the argument / proof fails at the stage of a final write-up, and had to be started again. Mathematical thinking is a chain of failures; the key obstacle to learning mathematics is failure to learn how to manage one’s failures.