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, wherein said swap frees up space in the memory by transferring data from the memory to a swap space comprising a partition of a Hard Disk Drive, a partition of RAM or ZRAM of the electronic device; 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 belonging to a group comprising: ∘ an information representative of a monitored activity of a program of said plurality of programs 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 focus within the predetermined time period, wherein the program is in the focus while other programs are running in background, doing background work or waiting for getting back the focus upon user request; - deriving a dynamic score delta from said monitoring information, said dynamic score delta being positive or negative, a score decrement value being applied 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; - terminating an execution of at least one program of said plurality of programs, 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, wherein said swap frees up space in the memory by transferring data from the memory to a swap space comprising a partition of a Hard Disk Drive, a partition of RAM or ZRAM of the electronic device; 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 belonging to a group comprising: ∘ an information representative of a monitored activity of a program of said plurality of programs 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 focus within the predetermined time period, wherein the program is in the focus while other programs are running in background, doing background work or waiting for getting back the focus upon user request; ∘ an information representative of a monitored activity of a program of said plurality of programs 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 focus within the predetermined time period, wherein the program is in the focus while other programs are running in background, doing background work or waiting for getting back the focus upon user request; - deriving a dynamic score delta from said monitoring information, said dynamic score delta being positive or negative, a score decrement value being applied 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; - terminating an execution of at least one program of said plurality of programs, 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.