Difference between using Swapfile or ZRAM

The majority of the devices that muOS supports have around 1GB of RAM and use microSD cards for storage. Now for general purpose use enabling Swapfile or ZRAM isn’t required. There are only a small subset of ports that may require a bit more extra memory.

What is a Swapfile?

A swapfile is a chunk of storage (as in your mSD card) used as virtual memory when RAM is close to being full. It’s the most basic swap mechanism you can get to increase available memory. However it can be quite slow on mSD cards and potentially wear out storage quicker over time.

What is ZRAM?

ZRAM is compressed blocks of existing memory used as swap space. It stays in RAM instead of writing to your mSD card. It’s faster than swapfile, avoids mSD card wear, and compresses data to make RAM go further. However it does use a bit of CPU and reserves RAM for itself.

Which one should I use?

Use ZRAM over standard swapfile.

It’s faster, safer for your mSD card, and gives you more usable memory through compression. A small swapfile can be added as a backup, but isn’t necessary.

Can I use both?

Yes you can however generally speaking if you need to pick one over the other ZRAM is the better and safer choice.

6 Likes