A weird problem has appeared on my laptop running Ubuntu 16.04. I have 8 GiB RAM and 10 GiB swap area. It worked fine, programs were swapping fast from the SSD, the swapped memory were mostly memory leaks and forgotten mmap anyway... but then something broke it. I have no idea what, I have not noticed it immediately. But now, it swaps incredibly rarely.

The swap space is almost unoccupied, I can have 95% RAM usage and swap space is only 5% full. If RAM fills up, it rarely swaps anything out, it freezes instead, sometimes it recovers after killing a program, but way too often, I have to do a hard reset.

I have checked the swappiness property, but it is set to 60 and setting it to 100 changes nothing. I upgraded Ubuntu to version 17.04, but it didn't help.

If I run a process that takes a lot of memory and uses it actively, it appears to swap out the memory of this process (that just allocated it!), making the process freeze again soon to get back the memory shortly aferwards, in a never ending loop. Almost none of the swapped out memory remains swapped out for long, although I am pretty sure there is enough leaked memory and unused programs to swap.

Any ideas what might be wrong?

  • Can you check that your swap is running? swapon will indicate if it is operational Nov 9, 2017 at 16:08
  • It is running, it occasionally swaps something. Writing swapon lists one partition with the parametres of my swap partition, with PRIO set to -1. Does it mean it has low priority or something?
    – Dugi
    Nov 9, 2017 at 16:13
  • The PRIO is an indicator of the relative priority of multiple swap spaces, and has not real function if you have only a single swap space. Nov 9, 2017 at 16:23
  • 2
    There is a related post to this which suggested that perhaps the swap format is faulty - the suggested cure is at https://askubuntu.com/a/847712/283721 Nov 9, 2017 at 16:28
  • Also mentioned in https://help.ubuntu.com/community/SwapFaq in the section "Why is my swap not being used" Nov 9, 2017 at 16:33

2 Answers 2


Having checked sysctl -a | grep swappiness to ensure that swappiness is set as desired, and swapon to ensure that the swap partition is mounted, there remains a possibility that the swap partition has been improperly formatted for some reason.

This can be corrected by

sudo swapoff -a
sudo /sbin/mkswap /dev/hda8
sudo swapon -a

where /dev/hda8 should be replaced with the partition or swapfile that is suspected of being bad.

The sources for this answer include https://help.ubuntu.com/community/SwapFaq in the section "Why is my swap not being used?", and Swap not being used


It turned out that the problem was entirely different. There was a leak of shared memory by a program that was always running. Shared memory cannot be swapped, so this leaking memory was always in RAM.

The memory belonged to some program required for the graphical environment to run (probably the intel video card driver), so it was always running and cleared only on restart. This caused an accumulation of leaked shared memory attached to a program that was never restarted that could not be swapped, leaving only little memory for other programs that could swap.

This problem could not be properly fixed in any good way because it was a bug in some crucial software package. I installed Ubuntu 18.04 as soon as it came out and the problem doesn't appear there, so it was probably fixed already.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .