I'm running openSUSE TW, 32 GiB RAM, 64 GiB swap (SSD).

Swap usage is zero up until the point when RAM gets entirely filled up with cache.
I'm using htop to monitor it. Cache is marked yellow/orange.

My system uses only 2 GiB of RAM, but the rest of it (30 GiB) is all cache, and then - instead of throwing away some cache to make space for other data that needs it - it just starts using swap, only a few MiBs, but I sware I can notice small freezes and the system sometimes slows down noticeably.
I noticed this usually occurs after copying a large amount of files.

Why is this happening, and what can I do about it?

I'm open to providing any requested info.

vmstat 60 5 vmstat 60 5

vm.swappiness = 1
vm.dirty_ratio = 20
vm.dirty_background_ratio = 10
  • 1
    you're not doing much on the system (avg 96% idle, 100% idle during the measurement). We also see swapd is zero, so no swap use at that time. A measurement at times when you're doing things on the system would be more helpful. Commented Aug 13, 2022 at 15:51
  • 1
    The case for swap is what you want to happen when the server's RAM is filled up with code/data segments from processes and there's a minimum allowable disk i/o cache reserved....and then a program requests more memory from the OS. Without swap the request will be denied, and most FOSS programs (and quite a few commercial ones) will crash in flames. With swap, the OS will start allocating from the disk device and the system will get slower. App slows down or hard crash? Cake Or Death?
    – Sotto Voce
    Commented Aug 13, 2022 at 18:07
  • 1
    64 GiB of swap is usually way more than you need on a system with plenty of RAM (16 GiB or more), unless you're running programs that need even more RAM than you have. (Usually that would be a performance disaster, unless a good fraction of that footprint isn't touched regularly). 4 to 8 GiB should be plenty to let the OS swap out "cold" dirty pages from typical desktop usage, leaving your actual RAM free for useful stuff. (I run 2GiB of swap on my desktop with 32G RAM; it's usually full, probably with pages from KDE crap and/or Chromium). Commented Aug 13, 2022 at 22:50
  • 1
    @SottoVoce: Linux overcommits memory by default (kernel.org/doc/Documentation/vm/overcommit-accounting), so allocation will only fail for really huge amounts of memory (or maybe if attempted with mmap(MAP_POPULATE) which prefaults the pages). So normally allocation succeeds, and more physical memory is needed only when a program writes to that allocated memory. If there isn't enough swap + RAM, the kernel has to kill something (OOM killer). Commented Aug 13, 2022 at 22:55
  • 1
    the "swap = 2 x RAM" recommendation was obsolete for more than a decade. Yes you do need at least some swap for many apps to work, but that means just a tiny amount like 512MB or 1GB is enough, or even better switch to zram or zswap like what many modern distros do. See How do I use swap space for emergencies only?
    – phuclv
    Commented Aug 14, 2022 at 7:53

1 Answer 1


You can set the swappiness to 0.The Linux documentation says:

"This control is used to define how aggressive (sic) the kernel will swap memory pages. Higher values will increase aggressiveness, lower values decrease the amount of swap. A value of 0 instructs the kernel not to initiate swap until the amount of free and file-backed pages is less than the high water mark in a zone.

The default value is 60."

Note that setting swappiness to 0 does not completely eliminate swap, it still swaps under conditions.

But is swap a problem? Just some swapped-out pages that are hardly used deserve to be swapped out, I think. To see if swap is a problem, run vmstat 60 for a while and look at the si and so columns. You'll probably see that they are 0 most of the time. Also, your column swpd will probably not change much. That would mean that the swapping is not a problem.

Is you have enough memory for what you are doing and you absolutely do not want any use of swap space for some exotic reason, swapoff the swap-space.

Note that, if you have system freezes, with these parameters, it is unlikely to be caused by swapping. Unless, of course four si and so columns in the vmstat output are high.


Your vmstat output suggests that there are a few pages swapped out. That is not something to worry about; there is no big swapping going on. Certainly not enough to cause system freezes.

  • I ran vm 60 10 and left my PC idle. Was I supposed to stress test it or something?
    – TypicalHog
    Commented Aug 13, 2022 at 15:50
  • 1
    @TypicalHog You should simply use your system as normal. If you don't see any swap-ins or -outs during normal use, the pauses and slowdowns you see are definitely not due to swapping because there was no swapping. (Even if you do see swapping, it's unlikely that the pauses you see are related to that, however, unless you have disk I/O issues.) ¶ Also, it's worth checking to see if swap-in events are counted only for actual swap space, or also for, e.g., loads of backing pages for mmap'd files, which can come from a filesystem.
    – cjs
    Commented Aug 13, 2022 at 23:13

You must log in to answer this question.

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