Computer-implemented method for controlling memory resources of an electronic device, said method comprising: - setting at least one memory swap size limit, said memory swap size limit being lower than a memory swap size defining a maximum size of a part of said memory resources used by said electronic device for swap, called swap memory space; and - obtaining a score for each program of a plurality of programs running on said electronic device, a high score corresponding to a low priority level; - obtaining monitoring information (I Monit), said information comprising: ∘ an information representative of a monitored activity of the program during a predetermined time period, ∘ an information representative of a learnt user's habit of use of the program, said information comprising a number of times the program gained the focus within the predetermined time period; - deriving a dynamic score delta from said monitoring information, said dynamic score delta being positive or negative, said deriving comprising applying a score decrement value to said dynamic score delta at each focus gained by the program; - adjusting the obtained score (AM-SC) of said at least one program by adding said dynamic score delta to the obtained score; and - terminating an execution of at least one program of said plurality, when said memory swap size limit is reached and the adjusted score associated with said at least one program is equal to or higher than a priority threshold associated with said reached memory swap size limit. - setting at least one memory swap size limit, said memory swap size limit being lower than a memory swap size defining a maximum size of a part of said memory resources used by said electronic device for swap, called swap memory space; and - obtaining a score for each program of a plurality of programs running on said electronic device, a high score corresponding to a low priority level; - obtaining monitoring information (I Monit), said information comprising: ∘ an information representative of a monitored activity of the program during a predetermined time period, ∘ an information representative of a learnt user's habit of use of the program, said information comprising a number of times the program gained the focus within the predetermined time period; ∘ an information representative of a monitored activity of the program during a predetermined time period, ∘ an information representative of a learnt user's habit of use of the program, said information comprising a number of times the program gained the focus within the predetermined time period; - deriving a dynamic score delta from said monitoring information, said dynamic score delta being positive or negative, said deriving comprising applying a score decrement value to said dynamic score delta at each focus gained by the program; - adjusting the obtained score (AM-SC) of said at least one program by adding said dynamic score delta to the obtained score; and - terminating an execution of at least one program of said plurality, when said memory swap size limit is reached and the adjusted score associated with said at least one program is equal to or higher than a priority threshold associated with said reached memory swap size limit.