Sometimes when I use Lubuntu 17.10 - fully updated, my RAM usage hits 100% and the system becomes unusable, if I'm "lucky" I can move my mouse about 1 pixel per 10 seconds... This makes it practically impossible to do anything even shutdown an applications. I am then forced to use the power button on my laptop.

I'm using a macbook pro retina late 2013, with almost fresh Lubuntu 17.10 install.

So far it has happened while I have spyder3 open and I've loaded too big files. It also happened when I clicked this link in firefox (WARNING: might crash) http://stats.oecd.org/restsdmx/sdmx.ashx/GetData/SNA_TABLE1. I even closed the tab before hitting 100% usage, but it just continued up to 100% and crashed. I only noticed because I closed the tab and saw RAM usage in spyder3 (I was not running any python3 scripts).

Is there a way to prevent this? Perhaps make sure a specific amount of RAM can only be used by the OS?

  • Anything you can provide to help narrow this diwn? Log files that have a notice? Otherwise there is not a lot to go on. (see /var/log/ and check the logs that got new lines after a crash) – Rinzwind Jan 12 '18 at 18:40
  • 3
    Please don't mark your question "SOLVED" and put the answer in the question, since that doesn't properly tell Ask Ubuntu that your question is solved. Instead, you generally put the answer in the answers section below and click the check mark next to your answer to mark it solved. In this case, FK-VH's answer should probably be accepted instead by clicking the check mark next to it since you needed to activate your swap partition. – Chai T. Rex Jan 12 '18 at 22:50

Probably your problem is caused by the system "thrashing" – moving many pages of memory to and from swap space at once, and not leaving time for real processes to execute.

If you want processes that use too much memory to be killed rather than making your whole system run slowly, you can disable swap. Running sudo swapoff -a will achieve this until a reboot; to disable swap permanently, you need to edit /etc/fstab to remove the swapfile/swap partition, by removing or commenting out the line with swap in the third column. For example, my /etc/fstab looks a bit like this:

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/ubuntu--vg-root /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sda1 during installation
UUID=fdedeca9-dafe-1a05-0866-7502fda1a7ea /boot           ext2    defaults        0       2
/dev/mapper/ubuntu--vg-swap_1 none            swap    sw              0       0

To disable swap, I would comment out the last line (by putting a hash # at the beginning of the line), then reboot. Make sure you don't modify any of the rest of the file, otherwise you might make your system unable to boot.

Caveat: If you disable swap and don't have enough physical memory for basic system services, the OOM killer may decide to kill one of those and lead the system to crash or become otherwise unusable (which the question says you want to avoid).

| improve this answer | |

If a process eats too much memory then the system should protect itself through the OOM killer, wich is a standard feature in any Linux system.

As estated in the best answer so far to How does the OOM killer decide which process to kill first?

If memory is exhaustively used up by processes, to the extent which can possibly threaten the stability of the system, then the OOM killer comes into the picture.

NOTE: It is the task of the OOM Killer to continue killing processes until enough memory is freed for the smooth functioning of the rest of the process that the Kernel is attempting to run.

The OOM Killer has to select the best process(es) to kill. Best here refers to that process which will free up the maximum memory upon killing and is also the least important to the system.

The primary goal is to kill the least number of processes that minimizes the damage done and at the same time maximizing the amount of memory freed.

To facilitate this, the kernel maintains an oom_score for each of the processes. You can see the oom_score of each of the processes in the /proc filesystem under the pid directory.

$ cat /proc/10292/oom_score

The higher the value of oom_score of any process, the higher is its likelihood of getting killed by the OOM Killer in an out-of-memory situation.

If your system crashes then I'd suggest to fine tune the OOM policy by adjusting the oom_score of your processes.

It is unlikely that the OOM killer was disabled but, to make sure, check if this command returns 0:

$ sudo sysctl vm.overcommit_memory
vm.overcommit_memory = 0


  1. http://www.oracle.com/technetwork/articles/servers-storage-dev/oom-killer-1911807.html
  2. https://superuser.com/questions/1150215/disabling-oom-killer-on-ubuntu-14-04/1150229
  3. https://unix.stackexchange.com/questions/153585/how-does-the-oom-killer-decide-which-process-to-kill-first
  4. https://www.kernel.org/doc/Documentation/sysctl/vm.txt
| improve this answer | |

Make a swap partition or swap file. These are like ram, but on HDD, so it is much slower. When you don't have enough RAM, the system will store data to HDD instead of ram. You need to specify size of it. It is generally recommended that you make it about the same size as your RAM.

swap file is easier to make, but doesn't allow you to hibernate to HDD.

swap file: https://www.howtoforge.com/ubuntu-swap-file

swap partition is harder to make if you have already installed your system and all HDD space is partitioned, but this allows hibernation.

swap partition: How do I add a swap partition after system installation?

| improve this answer | |
  • 1
    This is unlikely to help - the problem would probably actually be solved by disabling whatever swap is currently configured! – Ash Jan 12 '18 at 17:45
  • @Josh could you please elaborate on why disabling swap should be the solution to using 100% ram. It is against all common sense in my world. – Soren A Jan 13 '18 at 0:41
  • 1
    @SorenA I think the problem described ("the system becomes unusable, if I'm "lucky" I can move my mouse about 1 pixel per 10 seconds") is probably caused by the system thrashing, trying to swap many pages in and out at once. Disabling swap should cause the memory-hungry application to be killed rather than bringing the whole system to a halt. – Ash Jan 13 '18 at 0:48

@Josh answered:

I think the problem described ("the system becomes unusable, if I'm "lucky" I can move my mouse about 1 pixel per 10 seconds") is probably caused by the system thrashing, trying to swap many pages in and out at once. Disabling swap should cause the memory-hungry application to be killed rather than bringing the whole system to a halt.

This solved my problem.

I had a swap when I installed Lubuntu, however it got removed with gparted later. I didn't edit /etc/fstab which is what caused the problem. Once the swap was removed properly, the OOM killer started to work as intended.

| improve this answer | |
  • I would, but since @Josh chose to comment I could only rewrite it as an answer, but I have to wait 48 hours to select it as an answer. The two others give useful information, however they did not solve the problem. – Holykebab Jan 14 '18 at 12:12
  • 1
    Oh, my mistake. In that case I recommend to edit this answer to expand it with specific details about how to do this. (See also How do I write a good answer? for general advice about what sorts of answers are considered most valuable on Ask Ubuntu.) Additionally I'll ask Josh to write a proper answer of his own. – David Foerster Jan 14 '18 at 12:36
  • 1
    @DavidFoerster I wrote up an answer. – Ash Jan 14 '18 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.