There are four ways to memorize music. The first is by rote. You simply play it 3,000 times and the brain will memorize the movement and you will be able to regurgitate your notes. This method is highly to be avoided. Not only will you lose "it" in a few days but if you use it at performance, if the slightest hesitation creeps in, you will lose your place and not know how to recover. Knowing all your scales and arpeggios will service this method for in all music, if your hands just know where to go without thought, half the battle is done.
The second method is to know your music theory. Much like knowing how to spell. As you type, a lot of words just fall out of your fingers without thought because you know how to spell. You just know that "cat" is c. a. t. Or is it k. a. t? We musicians often combine theory with rote. Theory is the alphabet of music. If I asked you to play a C chord, you may be able to play it without thought because you know it is the first, third and fifth tone of the scale. Knowing that, if you have rote and know all your scales, you should be able to effortlessly invert, change octaves and easily transpose it. You don't have any of that memorized, you just know it. Like "cat" is spelled "Kat." Or is it "Kate?" Ah, improvisation. Just as adding an "e" to the end of a word makes the previous vowel long (Cap-Cape, tap-tape, sit-site) music theory has the same rules. If you know them, they will serve you in all musical endeavors.
Third is to hunt and peck, combined with rote and theory. I'm not even going to address that. I cringe at people who hunt and peck without theory. Like driving through a new city, you don't just "hunt and peck" your way around town. You use the sun, street numbers, maps, asking for directions, research, etcetera. So if you have a birds-eye view of the city in your head, and you know where north and south is, and can see the sun, and know what time it is (all like theory), you can then hunt and peck your way around. People who get lost boggles my mind.
Fourth is combining ear training (hunt and peck) with theory. For instance, I just know the notes to the Star Wars theme is 15 43285 43285 4342. Now, I don't know if those are correct but my ear and brain know what all intervals sound like and I just know the what the notes are (in any key because I know the numbers, not the letters). Combine rote, theory, hunt and peck with a knowledgeable ear, the song is yours forever. No "memorization" is needed.
Just like giving a lecture. You can memorize it word for word but if you slip up, you can crash and burn. However, if you know your topic, love and adore it, and know what is under the hood of your topic (rote, theory, trained) you can just use cue cards then combined with the aforementioned - hunt and peck your way through the lecture - FLAWLESSLY. Then if an audience member interrupts you with an ancillary question, you can improvise, effortlessly - or at least get back on track without losing a beat.