Ibn Mas’ood (RA) said,
“I feel that indeed someone will forget knowledge they had a acquired because of sins they commit.”
A man asked Maalik ibn Anas, ‘O Abu ‘Abd-Allaah! Is there anything that will improve my memory?’ Maalik ibn Anas, rahimahullah, replied, ‘If anything will improve it, it is giving up sin.”
Bishr Alhaafee, rahimahullah, said "A servant commits a sin, and is deprived [thereby] of performing tahajjud."
See how important it is to stop disobeying Allah SWT so we can keep His words in our heart, otherwise they are taken away.
And i think all that struggle to concentrate, listening repeatedly, intake of special foods to increase memory and all that wont help in memorizing and having it memorized for ever, unless we are very careful about not commiting any acts of disobedience to Allah SWT.