With regards to the effects of sins upon the ability of the student of knowledge to memorise, ‘Abdus Salaam ibn Burjis (d. 1425 AH) rahimahullaah said:
Disobeying Allaah, the Most High, is an obstacle to attaining Sharee’ah knowledge – because it (Sharee’ah knowledge) is a noor (light) from Allaah which He casts into the hearts of whomever He wishes from His servants.
And noor (light) and dhulmah (darkness) do not come together in a heart.
Therefore ibn Mas’ood radi Allaahu ‘anhu said:
Indeed I consider that a man (might) forget knowledge which he has already learned because of a sin which he does.
And may Allaah have mercy upon ash Shaafi’ee who said:
I complained to Wakee’ about my memorisation being bad
So he directed me to leave off sins
And he informed me that knowledge is a noor (light)
And the light from Allaah is not bestowed upon a person who is sinful
Quoted in ‘Awaa-iq ut talab of ‘Abdus Salaam ibn Burjiss rahimahullaah page 38, translated by Nasser ibn Najam