I have read a few replies on stackexchange that using swap is actually bad on a pi since the HDD is on SD card. By default Raspbian comes with 100MB swap enabled. Should I disable swap altogether? Are there pros or cons to doing so?
1 Answer
Swap is only used if you run out of memory.
The Pi normally uses a swapfile, which if not used has no penalty, but if required is slow.
Without swap the OS will terminate low priority processes or crash. The choice is yours.
-
Typically if swap is enabled there is a threshold before pages are swapped out, this is controlled by kernel parameters.(
swappiness
among others). Because this behavior is dynamic there is some argument to disable swap to preserve the SD Card, on the other hand, it is less reasonable to increase the threshold to 100% because this will cause more thrashing than the default value as the OS tends to swap out cached files and unused code sections first, and you preclude pre-emptive swapping with a large swapiness value– crasicCommented May 21, 2018 at 3:02