Cannot allocate memory – Fix for login error

Do you see this message on every login to your Ubuntu system: “Could not load list of meta packages: [Errno 12] Cannot allocate memory”? The error indicates there was not enough RAM available to complete the task. Here I explain where the message comes from and how to get rid of it.

  1. Origin of the ‘cannot allocate memory’ error
  2. Track down the problem
  3. — Try to avoid swapping
  4. tl;dr – Just remove the error
  5. Related stuff

Origin of the ‘cannot allocate memory’ error

On login the script at: (1)


is ran to notify you when an upgrade is available. After a check it runs: (2)


which in turn calculates if the last upgrade check ran more than 86400 seconds (one day) ago. When the answer is yes it will run: (3)

/usr/lib/ubuntu-release-upgrader/check-new-release -q

which actually checks if a new major Ubuntu version is available and write the output to this static file for caching: (4)


The error on your login screen is only the cached text file (4). It can be a day old and no longer relevant.

Track down the problem

The fact that the system cannot allocate memory is a pretty nasty problem that you should really track down. If a simple upgrade checker cannot complete because of a RAM issue, imagine what happens with the heavier apps. This can result in serious data loss or even a broken OS when the problem persists.

You can manually run the upgrade check command (3) to see if the memory problem still exists. When it does you need to either optimize some apps, upgrade your RAM or resize the swapfile. Then after a day the error should disappear. A great tool to help you find memory hogs is ‘htop’. It is much like the standard ‘top’ command but a lot nicer with colors, search, filters, actions, sorting and navigation. This way you can easily track down the apps that claim the most of your memory so you can start optimizing their configurations.

— Try to avoid swapping

Make sure to only increase the swapfile when the other options are not enough. Swap is only intended to cover temporary problems. For example, when you have a hardware defect or when a once in a while task needs just a little bit more RAM. Normally you should barely use the swap at all. Another cause of increased RAM usage could be from slow CPU processes, as the processor’s queue is also stored in the memory. When you let the swapfile take care of your memory problem, your system will eventually start to become very slow. Disk I/O will peak or it can even wear out your SSD because of the huge amount of writes. You should try to keep the swap size below 512MB. When you need even more, it is time to upgrade your hardware.

tl;dr – Just remove the error

Deleting the static file will temporarily remove the ‘cannot allocate memory’ error from your logins. On your next login the file will be recreated with fresh information. However, if the memory problem is not resolved the error may return.

sudo rm /var/lib/ubuntu-release-upgrader/release-upgrade-available

Leave a Reply

Your email address will not be published. Required fields are marked *