Time for the classic https://www.linuxatemyram.com/
Tldr it's cache, its a GOOD thing and you WANT it to happen. The memory is available if applications need it
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
Time for the classic https://www.linuxatemyram.com/
Tldr it's cache, its a GOOD thing and you WANT it to happen. The memory is available if applications need it
The memory is available if applications need it
That's not true, since it's reserved memory.
Reserved memory
Some times. This is actually where we run into one of the issues with open source software, competing standards. Some tools will call your swap or cache "reserved" regardless if it's actually being used or not. They're not wrong, it is reserved, but it's reserved for usage in emergency situations rather than being reserved in the way we look at the rest of memory
I don't see anything wrong here. Ram is supposed to be always as full as possible.
What is not needed by running programs should be full of disk pages cached. A system with lots of free ram is oversized or abnormal.
Also, today's kernels require swap space. On disk is a must for a server, and maybe consider even zram.
Having swap will allow the kernel to organize it's memory usage even better.
Don't over think ram as that is a field in which you will be wrong and the kernel will be right 99%.
When you want to turn it on, instead unplug it and go start a farm. Problem solved, requires zero ram
Although you may eventually want a ram
You might be a little surprised at how much compute goes into running a modern farm.
Why do you care so much about memory usage?
Unused RAM is wasted RAM.
It’s apparently jumped by almost a third of all of their available RAM. That’s pretty significant.
I meant like in general..
I do agree it's worth investigating if it happens again. My best guess so far would be some kind of data written to a tmpfs. That'd explain it not being associated with a particular process, yet counting towards actual used RAM.
Not really. Doesn't sound like they are having any problems.
I said it was significant, not that they were having problems.
If they're not having problems then why investigate?
You can also drop cache for debugging by running something like echo 3 | sudo tee /proc/sys/vm/drop-caches
But remember that the kernel knows best
this RAM will automatically be freed up when needed and you should never run this except for debugging (or maybe benchmarking).
Rimworld mods sometimes occupy 10gb RAM after a crash/force-close. That one helps.
But don't set up a cronjob running it regularly, that causes issues.
It's allocated memory in the cache. It's not used, it's earmarked for first usage.
This is standard memory management.
I’m pretty sure only the yellow bar on the right of that indicator is cache. Green is actually being used by processes.
Uh, memory metrics in Linux are a pain. The only tool that reports most cached as available is htop. free, top and a lot of other software (like node_exporter) will report that a lot of cached memory is not available.
To OP: don’t worry, a lot of Linux tools are smart enough to give back memory if memory pressure rises.
This is from btop.
Are you having performance problems? If not, what do you care?
You mention this is a server VM and so you probably don't need NetworkManager or the wpa_supplicant services. If you don't wish to setup a static IP for the server VM then install and use dhcpcd instead of NetworkManager/wpa_supplicant.
Unless you need to use WWAN (2G/3G/4G/5G) devices, you don't need ModemManager.
Depending on your workflow, consider reducing the number of agetty instances to 1. With a single agetty instance, install and use tmux multiplexer when you need more sessions on the physical VM console.
I don't have any experience of using seatd/elogind but I think you may be able to configure USE flags such that you only need seatd installed (i.e. don't need elogind) and since you need seatd only for running a WM occasionally, why not use seatd-launch to start the WM and not have the seatd daemon running constantly. See: https://github.com/swaywm/sway/wiki/Running-Sway-with-seatd,-elogind-or-systemd%E2%80%90logind#seatd-launch
Lastly, the largest chunk of memory used other than the processes you can see in htop will be the Linux kernel. The Gentoo distribution kernel will have hundreds of drivers for real hardware which make no sense in a Kernel that will be used in a VM (unless you plan to use PCI/USB pass through). So, you should create a custom kernel (https://wiki.gentoo.org/wiki/Kernel/Gentoo_Kernel_Configuration_Guide) which is tailored for a KVM guest.
To do this (the following are not detailed instructions but just guidance):
Note 1: The additional "*.config" files mentioned above will need to be copied into the correct place before make will find them and I've provided some some sample config files you can use to start with below:
Note 2: I'm not associated with the above github repo(cyano-linux/qemu-guest-kernel) but I have referenced it when I needed to setup a custom kernel. You can find a little documentation for the above kernel config here: https://github.com/cyano-linux/qemu-guest-kernel/blob/master/config.md
free -m
and slabtop
output.
I don't know when you had a clean boot using only 200MB, but it wasn't in the past few years with what you're running there.
Anyway, with half your RAM still available, things are more than fine. Make sure you have swap enabled, and you won't get OOMKill situations that tear things down.
total used free shared buff/cache available
Mem: 3354 350 3032 1 171 3004
Swap: 8191 0 8191
on another reboot the memory dropped back down?
It's just allocated in buff/cache. Only 350MB hard commit. You're fine.
The buff/cache will free automatically when an application needs ram, until then it's useful for speeding up the system.
Remove Modemmanager if you don't use it, replace Network-manager and wpa_supplicant with connman or iwd, maybe look if you can remove elogind since you already use seatd.
Btw, syslogd, the reference implementation? Not syslog-ng?
And, uh, Systemd doesn't do supervision by itself, needs a service for it?
Iwd is so smooth to use
If you can live without Networkmanager, I'd disable it and move your network setup to a static ip. Networkmanager can hog resources.
Yea, this kind of blows me away. Maybe I'm out of the loop, but 3-4 processes each eating away that much memory? Just to deal with the network stuff? Holy fuck.
MEM% for each NetworkManager process is 0.4 % of 3.28 G ≈ 13.1 M. Additionally, almost certainly most of this will be shared between these processes, as well as other processes, so you cannot just add them together.
The virtual size (315M) is the virtual memory. Quite clearly only 13.1 M of this are actually in use. The rest will only start getting backed by real physical memory if it is being written to.
The way this works is that the process will get interrupted if it writes to a non-physical memory location (by the memory management unit (MMU); this is known as a page fault), and executions jumps to the kernel which will allocate physical memory and alter the virtual memory table, and then proceed with the execution of the write operation.
Many programs or library functions like to get way larger virtual memory buffers than they will actually use in practice, because that way the kernel does all this in the background if more memory is needed, and the program doesn't need to do anything. I.e. it simplifies the code.
Thank you for explaining it. I haven't been in the *nix world for years, keep thinking I'll get back into it.
Well I wasn't thinking about memory (and maybe that's the reason some people downvoted that comment...) but because in my experience NetworkManager takes time starting at boot and with months/years it was taking more and more time. I reset it once and kept doing the same thing.
As you said you're planning on a home server kind of thing I'd think setting up a static ip is a good idea and NetworkManager is just an overkill for that - you could very well go along with Gentoo's netifrc.
Just download more RAM lol
We joke but zram swap works wonders on low resource systems sometimes
It just fucks your CPU usage
I rather let it fucks my CPU than let my whole computer fucks itself
I've used swap on my steamdeck for a while and it's really only improved performance in memory-bound situations when I've used it.
Not as badly as you'd expect, modern compression is pretty quick using the lz*'s and you're only expending cycles when you're hitting swap