Sunday, March 23, 2025

Raspberry Pi zram swap

Raspberry Pi computers may not always have the best amount of RAM available. For small embedded applications, this is just perfect, no precious ram wasted by remaining empty.
However, depending on the application, more memory might be required. The fallback would be virtual memory. In big server installations, swap is not even a topic. However, if an SD-card is were the files live on, SWAP is somewhat out of the picture.

If CPU power is not an issue, ZRAM might be a solution of the RAM-shortage of an RPi-application. 
While my RPi500 has plenty of RAM, I installed ZRAM anyways.
This is what my present memory situation looks like:

               total        used        free      shared  buff/cache   available
Mem:         8131616      835544     6173708      103560     1315828     7296072
Swap:        4270584           0     4270584

NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo-rle       3.9G   4K   80B   12K       4 [SWAP]

NAME       TYPE      SIZE USED PRIO
/dev/zram0 partition 3.9G   0B  100
/var/swap  file      200M   0B   -2

And yes, the RPi500 is equipped with 8GB of RAM and 4 CPU cores. 
Presently I would not know how to fill up all the memory available to me.