Based on the screenshot, is this normal? In a couple of days, it will increase to 100MB of swap used (default is 100MB), but with low ram. I am running Pi-hole, PiVPN, log2ram, and No-IP.

enter image description here

  • With all you have running, including GUI (which you failed to mention) seems about right ... oh and if usage slowly creeps up, usually means something has a memory leak Jun 5, 2020 at 4:41
  • By usage, do you mean CPU usage? I notice that the CPU load has been higher than before. What is a memory leak? How would you fix that?
    – AsianXL
    Jun 5, 2020 at 4:43
  • by usage, I mean memory usage, as you said "In a couple of days, it will increase to 100MB of swap used" - and a memory leak is not something you can fix - it's something the developer of whatever program is "leaking" memory needs to fix - basically, if a program uses more and more memory as time goes on, it probably has a memory leak. Not sure if it was fixed but pi-hole was reported to have such a leak about a year ago discourse.pi-hole.net/t/memory-leak/16314/12 Jun 5, 2020 at 5:17
  • 1
    It's not a memory leak. It's totally normal.
    – goldilocks
    Jun 5, 2020 at 15:00

2 Answers 2


There's a good article on nixCraft regarding the "correct" amount of swap. It's worth reading I think because it suggests that there is no single "correct" amount for all applications.

If we look at Raspberry Pi's default allocation of swap, it's actually quite low. On my systems for example:


$ free -m
              total        used        free      shared  buff/cache   available
Mem:            874          50         315          44         509         716
Swap:            99           0          99


$ free -m
              total        used        free      shared  buff/cache   available
Mem:           1939          67        1568          24         303        1765
Swap:            99           0          99

If the nixCraft article referenced above is a reasonable "yardstick", the swap allocation on Raspberry Pi was penurious, and it's getting worse. You didn't ask about increasing the size of the swap, but if anyone wanted to do that, the clue is in /etc/fstab: dphys-swapfile.

It can be changed by editing /etc/dphys-swapfile


Stuff that ends up in swap and is not actually being accessed much will stay in swap regardless of the RAM usage. Stuff may actually end up in swap even when there is enough RAM for it depending on the nature of the data.

If every time RAM usage dropped enough to move something out of swap the system moved something even though there was no immediate need to access it, you'd end up with a context that potentially involves a sort of thrashing. For example:

  • Process A is done with a chunk of RAM and releases it.
  • The kernel takes the opportunity to move some stuff out of swap into RAM, although there is currently nothing there being accessed.
  • Process A needs a chunk of memory again, but the RAM is too full because of the junk moved into there from swap. The kernel can either:
    • Identify pages which are seldom accessed and move them (possibly including the stuff that was just moved out, meaning now otherwise dormant data is just being moved back and forth pointlessly).
    • Allocate process A a chunk of swap instead. This is not a desirable scenario.

Point being, it's totally normal and lots of smart people have been tuning this mechanism for decades. The behaviour reflects this. It is possible to tweak that using a sysfs interface, but the usual recommendation is that you leave it alone unless you understand what you are doing (which is not as trivial as it may appear).

Note that your swap usage is not really "high". 100 MB of swap (it looks like that's what you have) on a system with GBs of memory is unusual. The norm is to have a swap space that is bigger than the RAM space, which is why this looks so significant in htop. If you had 1 GB of swap (double your RAM), the red bar would obviously be much shorter.

So, if you think this is a problem and you want a solution, use a bigger swap space. What you have now means it is effectively impossible for "high" swap usage to occur, if it is considered relative to RAM (and not an arbitrary limit).

As an example, the laptop I'm working on has 16 GB of RAM and 18 GB of swap. Htop shows me as using exactly half the RAM right now, but there is still ~700 MB of swap occupied.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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