0

enter image description here

I usually sleep my laptop. After waking, the swap usage has increased.

2
  • 2
    I am not sure what the question is ? Depending on what you mean by sleep the content of RAM would be written to disk (swap), and after waking up, some of that content will be read back in RAM. – Soren A Feb 20 '19 at 15:04
  • 3
    Possible duplicate of How do I configure swappiness? @SorenA An 8GiB RAM wouldn’t fit into 2GiB swap… – Melebius Feb 20 '19 at 15:09
2

The problem is that you've got 8G RAM. The swap file/partition WILL be used... and in fact, you might wish to increase your swap file/partition to 4G. Changing the vm.swappiness parameter might change swap usage, but with 62% of RAM used, as in your example, you WANT it to swap.

With no swap file/partition, or with too little swap file/partition, understand that in the current example (100%-62%=)38% of unused RAM is used a disk/file buffer/cache. With no/little swap, and RAM usage increasing, and disk/file butter/cache being reduced and reduced, and OOM (Out Of Memory) process trying its hardest to keep the machine running, it'll eventually run out of resources, and with no where to go, and it'll hang/crash the computer.

4
  • @Melebius swap is probably the most misunderstood feature of OS's. In this case, running 8G RAM with no swap, running at 62% memory utilization, will very quickly run out of ALL RAM, and the OOM process will try and do its best to manage a full RAM situation, and the computer WILL hang, and maybe even crash. – heynnema Feb 21 '19 at 13:56
  • So do I understand you correctly that you really meant: “The problem is that you are using nearly all your RAM”? I downvoted because I found the reasoning “that you've got 8G RAM” incorrect. I’ve got a Xubuntu 16.04 VM with 1.5 GiB RAM and almost not swapping at all. I’ll remove my downvote for sure if you edit your answer with the clarification. – Melebius Feb 21 '19 at 14:05
  • 1
    @Melebius The 8G RAM came directly from their image. Understand that the "38%" of unused RAM is used a disk/file buffer/cache. With no swap, and RAM usage increasing, and disk/file butter/cache being reduced and reduced, and OOM trying its hardest to keep the machine running, it'll eventually run out of resources, with no where to go, and it'll hang/crash. Also, Xubuntu running with 1.5G RAM AND a swap file, really can't be compared here, without knowing how it's being utilized, and remember, it's a low resource OS. The OP's question was "how to reduce swap", not how to run without it. – heynnema Feb 21 '19 at 14:14
  • @Melebius and... as you can see from the image, 67% of swap is being used right now. – heynnema Feb 21 '19 at 14:17
0

Run fewer memory-using processes. Swap is used when memory requirements exceed what's available. Without sufficient swap (2*RAM is my recommendation).

2
0

You can manually disable swap usage of any kind through the terminal:
use

swapoff -v [path of associated logical volume]

I believe that you can also reduce that with lvreduce (but look at the man page for that).

2
  • but now looking at your case i think you want swap – Norman Feb 20 '19 at 18:42
  • No, lvreduce is a LVM command to reduce a LVM volume size. – heynnema Feb 21 '19 at 0:08

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