RIP
There is little I can add here that had not been said already, and I particularly agree with comments from David Bello, HZPiano and Vagfilm. I've experienced all of those things myself, either directly or with friends.
It has been already said, but I will stress it: the typical "memory loss" happens for memories which are well formed (say, you forget the name of your friends or of everyday's objects), whereas you are struggling with memory (trans)formation transforming a temporary memory which you remember "now, for few minutes" into the "permanent" status. This happens during sleep. If you are sleeping less than 7 hours a day, you are hurting yourself. If you are sleeping less than 6 hours a day, you are severely hurting yourself. If you are learning many things you need to sleep at the very least 8 hours per day and probably longer. Two anecdotes:
- I have a younger friend, professor at famous university. Earlier in his life (probably he was in his 30s) he "decided" that he had no time to do all his grants, research and other professory things, so I decided to sleep at most 6 hours a day. He acted, believed and claimed to be "just fine" but he could not remember anything new. I told him the very same things over and over, in person, every day (we were in the same town at the time) and he will always forget it as it never happened. On one hand it was funny, like Groundhog's Day movie if you know that. On the other it was very scary. He did not have any clue this was happening to him, and the problem totally disappeared when he went on regular sleeping schedule
- My doctor told me to set an alarm at night, when I am supposed to go to bed, and follow it strictly, rather than putting it in the morning when I need to wake up. If I need to wake up earlier, just set the night alarm earlier (since I have troubles getting asleep, I need to do that several days in advance, otherwise it's a moot point). I found that I memorize and remember things much easier that way, and that if I study a new thing (either for fun or for work), I automatically sleep more in the morning, compared to days when I just "perform tasks" instead. To avoid this automatic change to disrupt my daily life (e.g. time I need to be at work), I set up my schedule such as that if I wake up an hour or two later, I still am just fine (like it happened today, I woke up an hour "late"…. i.e. it's 7am here now, and if it were business days I was ready to go to work)
The "tricks" of knowing what you are doing of course can also help, for example knowing the structure of the piece, the "big picture" of the directions of the repeats, the harmonic progressions etc. And also, for this particular piece you are talking about, do you need a perfect note-for-note accuracy? If not (and perhaps even if so, depending on how you study) you can start with a "sloppy" version in which you just do arpeggios with the appropriate pattern/rhythm on the main harmonies for the offending part, and add a sketch of a melody later, and auxiliary notes at the end. Sort of like if you were memorizing a speech…. not sure if you have ever done that, but you never memorize it word-for-word upfront, you just make a plan for the main points you want to make and how they related to each other, and how you transition from one to another and so on…. (well unless you are one of those politicians who just babble randomly like if they were having a bad dream, but I digress 🤣 )
Hope this helps!