I've got a method that's a bit different to the others mentioned here, but then again I guess it doesn't contradict what has been said.I haven't got a photographic memory, but I tend to be able to see the score in my head naturally after a while of knowing the piece. However, there are usually some bits where I'll always forget what happens next. When this happens, I will not immediately run and grab the music to see what the notes are. I'll try and guess them and usually after a few tries I'll find the next part (if not, then I will run and look at the score). After having to find the next part the hard way, I'll keep going in this way and then do it all again. I find that forcing myself to figure out what to play makes it end up sticking in my mind more. Also, especially in the works of Bach, I'll discover many of the sequences this way. I think, OK, here's a tune using a broken diminished chord, and then it repeats itself down one tone, etc. So, then, if you know the first part of the sequence, you'll know the next ones too.I hope I have added something of use.