It will vary from piece to piece , you don't state what kind of memory there are several Ie muscle memory (least reliable )Theoretical ie to know musically where in the form you are while playing. You also away from. Keyboard can state the key and harmony of the measures you are playing , you can state the notes or melodic line Visual , you can see the score in your mind or can close your eyes and see it in your head away from the paino
You also forgot aural... some people are so good with their pitch that they memorise the sound of the piece and in a memory blank, work out the notes from the sound in their head.
But for example, you can memorize entire bars instantly by just knowing that "this is a c major scale that starts on g3 and ends on g5, and in the left hand there is a G7 chord (the dominant) in root position". Or "this is an E major scale in triplets, except he has added THIS and THIS chromatic tone HERE and HERE". Beethoven in particular constructs a lot of his music from basic scale and triad building blocks, which makes it easy to memorize in this way.