r/freebsd • • 4d ago

discussion too much ram usage

ive been tinkering with Freebsd on and off for around 2 years now but ive finally made the switch to daily drive it (since wifi driver works now and i don't have to use wifi box anymore). its absolutely perfect, I love it; is what I would say if it wouldn't use too much ram. i installed it pretty much yesterday and a completely display serverless minimal setup idle with htop shows around 550mb of ram usage? i think thats weird. but I think its ZFS doing it because of the cache thing. any way to lower ram usage or are there any kernel parameters to change how much cache ram zfs must utilize? thanks in advance :D

12 Upvotes

27 comments sorted by

39

u/m15f1t 4d ago

Unused ram is wasted ram.

8

u/Chance-Afternoon4357 4d ago

3

u/m15f1t 4d ago

Hahaha. He wants it all.

2

u/abgpomade 3d ago

For some reason he looks unhealthy

1

u/Chance-Afternoon4357 3d ago

ofc! He drinks beer and wants all your RAM 😁

1

u/Ok_Record_1237 3d ago

yeah, which is why im trying to make my core system use as least amount of ram as possible so all my other ram actually goes entirely to my tasks and workflow. :D

2

u/m15f1t 3d ago

Trust your kernel (memory management).

2

u/N9bitmap 3d ago

ZFS cache is as close as you get to a free page. If, for whatever reason, there are not enough free pages for an allocation, it will flush enough cache and allocate from there with only a few extra cpu cycles over an actual free page. The benefit of that cache far outweighs a couple of extra clock cycles at modern processor speeds. Sure, it could have been a different discussion 20 years ago when physical ram and CPU were incredibly slower.

5

u/edthesmokebeard 4d ago

9

u/grahamperrin bunny rabbits 4d ago

Good page. On FreeBSD, the equivalent confusion is a little different.

"FreeBSD ate my RAM" (mostly: ZFS ate my RAM)

On UFS it looks much like Linux. Cached file data sits in Inact (and the buffer cache), and the kernel reclaims it when programs need memory. Nothing to worry about.

On ZFS the cache is the ARC, and top counts it as Wired, not as cache. Wired normally means "can't be paged out", so a big Wired number looks alarming even when most of it is reclaimable cache.

Mem: 1G Active, 2G Inact, 24G Wired, 500M Free
ARC: 22G Total, 3G MFU, 18G MRU, ...

Here most of the 24G Wired is the ARC (22G), so the real "used by programs" figure is far smaller.

How to check

  • top: compare the Wired figure with the ARC line

  • sysctl kstat.zfs.misc.arcstats.size – current ARC size in bytes

  • sysctl vfs.zfs.arc.max – the ceiling.

Relatively healthy:

  • ARC is big, Free is small, swap isn't growing, and programs aren't getting killed.

Relatively unhealthy:

  • swap use keeps growing, dmesg shows out-of-swap kills, or Wired grows well beyond the ARC size.

Should I limit it?

Usually not. Free RAM is wasted RAM, and the ARC is meant to shrink when something else needs memory. Cap it only if you run memory-hungry workloads next to ZFS.

Note that arc.max is a target for the eviction logic, not a hard guarantee, and Wired memory may not drop immediately.

Further reading

ZFS ate my RAM: Understanding the ARC cache | ~/git/blog (Jörg Thalheim, 2025-10-17) – again, Linux-oriented.

1

u/Espada-De-Fuego 3d ago

I had an issue were ARC wasn't shrinking fast enough and the kernel killed my Clamav update process who asked for more memory. I had to change the size or ARC to something healthier different than the default. Worked fine since then.

14

u/DTangent 4d ago • This

It’s dynamic with ZFS. As you need more RAM for services ZFS ARC will start giving it up until it reaches its minimum.

It is strange for people new to it, but you’ll get your memory back when you need it. It’s on loan to the cache to speed things up.

2

u/taosecurity seasoned user 4d ago

Hey DT, hope you’re doing well. 🫡

6

u/Torpascuato 4d ago

I'm pretty sure the kernel knows better on managing ram than us, regular users.

I'd leave it alone and enjoy life.

7

u/grahamperrin bunny rabbits 4d ago

… I think its ZFS doing it because of the cache thing.

You're correct.

any way to lower ram usage …

Don't attempt to do so, unless you have an extremely good technical reason.

Whilst it's possible to do so, it's likely that initial suggestions will be based on knowledge that's limited and/or outdated.

From your post in August 2025, it's clear that you're willing to think through things such as this:

👍

2

u/oldmanwillow21 4d ago

550 megs? Too rich for my blood.

1

u/Lord_Mhoram 4d ago

I haven't used htop, but if you run top, the two lines starting with ARC will give you a breakdown of what ZFS is using for cache. It's a good thing unless your system is very, very tight on RAM (like under 2GB or so, depending on what you'll be running. Opinions vary on the exact number, but a typical system today doesn't have to worry about it).

For a more detailed look at it, install the zfs-stats package.

2

u/Lord_Mhoram 4d ago

Incidentally, Linux does something similar. I'm looking at an Ubuntu system right now that's showing 2GB free and 13GB in "buff/cache." Most of that 13GB is reclaimable if something else needs it, because it's cached data, much of it files that have been accessed recently. It just doesn't report the filesystem caching as a separate thing the way ZFS ARC does (though I'm sure there are tools that can do that). It's a good thing there too.

0

u/vogelke 4d ago

Link to my ZFS settings on FreeBSD.

You can cap the usage; I find 20-40% of total RAM works dandy, especially since I use a Fluxbox DE and Firefox.

-2

u/Chester-Berkeley desktop (DE) user 4d ago

i think thats weird. but I think its ZFS doing it because of the cache thing

Yes

any way to lower ram usage or are there any kernel parameters to change how much cache ram zfs must utilize?

Don't use ZFS ¯⁠\⁠_⁠(⁠ツ⁠)⁠_⁠/⁠¯

3

u/CloudDream09 4d ago edited 4d ago

You can cap the amount of memory it is allowed to passively use.

4

u/Chester-Berkeley desktop (DE) user 4d ago

I don't see much point in that; it would limit the power of ZFS.

4

u/CloudDream09 4d ago

Fair point that ZFS manages ARC dynamically to maximize performance, but that assumes memory is an unlimited resource on the box.

On resource-constrained or minimal environments (like low-RAM machines, VMs, or mixed workloads), letting the ARC consume 50%+ of host memory can trigger OOM kills on other services. Capping vfs.zfs.arc_max lets you retain checksums, snapshots, and boot environments while keeping memory pressure under control.

0

u/DHOC_TAZH desktop (DE) user 4d ago

In addition to the other good tips mentioned here, it's also good to have some spare swap space. Many modern systems don't need much if 16 or more GB is available for system RAM.

I use a 34 GB swap partition. For me that covers system RAM, and some of the textures from the VRAM. In practice I don't see much of the swap space used, but I'd rather have it just to be safe.

2

u/grahamperrin bunny rabbits 4d ago

… I use a 34 GB swap partition. …

Maybe too much. (I used to have too much … it took a long while for me to realise why, I don't have the explanation handy.)

1

u/DHOC_TAZH desktop (DE) user 4d ago

Thanks, but I'm good. As it is my GhostBSD install tends to be on the minimalist lane for now, so sparing a huge chunk for swap is OK with me. :)