this post was submitted on 19 Jan 2026
19 points (95.2% liked)

Selfhosted

54680 readers
751 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

  7. No low-effort posts. This is subjective and will largely be determined by the community member reports.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 2 years ago
MODERATORS
 

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:

Answer

My Results

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.

you are viewing a single comment's thread
view the rest of the comments
[–] tal@lemmy.today 4 points 11 hours ago (1 children)

If oomkiller starts killing processes, then you’re running out of memory.

Well, you could want to not dig into swap.

[–] a_fancy_kiwi@lemmy.world 1 points 11 hours ago (3 children)

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.

[–] eager_eagle@lemmy.world 8 points 8 hours ago (1 children)

if my system touches SWAP at all, it's run out of memory

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.

[–] a_fancy_kiwi@lemmy.world 1 points 34 minutes ago

From what I can tell, my system isn’t currently using swap at all but it does have 8GB of available swap if needed.

To make sure I’m following what you are saying, if I upgraded my system to 64GB and changed nothing else, and let’s assume ZFS didn’t trying caching more stuff, would there still be a potential for my system to use swap just because the system wanted to even if it wasn’t memory constrained?

[–] EarMaster@lemmy.world 5 points 7 hours ago (1 children)

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…

[–] a_fancy_kiwi@lemmy.world 1 points 29 minutes ago

I’m currently not in a situation where swap is being used so I think my system is doing fine right now. I’m not against swap, I get it’s better to have it than not but my intention was to figure out how close is my system getting to using swap. If it went from not using swap at all to using it constantly, I’d probably want to upgrade my ram, right? If nothing else just to avoid system slow downs and unneeded wear on my SSD

[–] victorz@lemmy.world 1 points 9 hours ago (1 children)

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.

[–] B0rax@feddit.org 1 points 6 hours ago (1 children)
[–] victorz@lemmy.world 2 points 5 hours ago

Yeah, on multiple computers. Linux I feel will just happily hand out memory on loan like a bank rather than from what's actually available. Then when it runs out, the next request for more memory will just freeze the system. ☠️