I recently noticed that htop displays a much lower ‘memory in use’ number than free -h, top, or fastfetch on my Ubuntu 25.04 server.
I am using ZFS on this server and I’ve read that ZFS will use a lot of RAM. I also read a forum where someone commented that htop doesn’t show caching used by the kernel but I’m not sure how to confirm ZFS is what’s causing the discrepancy.
I’m also running a bunch of docker containers and am concerned about stability since I don’t know what number I should be looking at. I either have a usable ~22GB of available memory left, ~4GB, or ~1GB depending on what tool I’m using. Is htop the better metric to use when my concern is available memory for new docker containers or are the other tools better?
Server Memory Usage:
- htop =
8.35G / 30.6G - free -h =
total used free shared buff/cache available
Mem: 30Gi 26Gi 1.3Gi 730Mi 4.2Gi 4.0Gi
- top =
MiB Mem : 31317.8 total, 1241.8 free, 27297.2 used, 4355.9 buff/cache - fastfetch =
26.54GiB / 30.6GiB
EDIT:
tldr: all the tools are showing correct numbers. Htop seems to be ignoring ZFS cache. For the purposes of ensuring there is enough RAM for more docker containers in the future, htop seems to be the tool that shows the most useful number with my setup.


That’s pretty much where I’m at on this. As far as I’m concerned, if my system touches SWAP at all, it’s run out of memory. At this point, I’m hoping to figure out what percent of the memory in use is unimportant cache that can be closed vs important files that process need to function.
If that’s the case you should look into your swappiness settings. You can set this to zero meaning the swap will only be used if you’re actually out of memory, but as others have noted that is maybe not a healthy decision…
That’s a swap myth. Swap is not an emergency memory, it’s about creating a memory reclamation space on disk for anonymous pages (pages that are not file-backed) so that the OS can more efficiently use the main memory.
The swapping algorithm does take into account the higher cost of putting pages in swap. Touching swap may just mean that a lot of system files are being cached, but that’s reclaimable space and it doesn’t mean the system is running out of memory.
It’s just that the system freezes for me when I used to run out of memory when I had only 32 GB of memory. Then I couldn’t do anything and had to hard reset the computer with its reset button. Then it would be nice to have a little bit of swap to kill some stuff before literally everything just stops working.