Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How does RAM usage work?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
L1NTHALO
n00b
n00b


Joined: 27 Aug 2024
Posts: 14

PostPosted: Sun Oct 20, 2024 9:22 pm    Post subject: How does RAM usage work? Reply with quote

I always want to keep my systems as minimal as possible, that's a huge reason why I switched to gentoo.
On of the most fun parts so far has been checking my idle RAM usage after installing an OS (arch, windows, gentoo etc), the lower the better.

However I have realized some inconsistencies. First of all Gentoo is supposed to be minimal but I often get the same or just slightly higher RAM usage on arch. Sometimes gentoo uses more RAM.

Also on my different gentoo installs memory usage varies. For example kernels that I deemed more minimal than others use the same or more RAM than bigger kernels. And I noticed that systems with more GB of ram use more of it idle.

I used Hyprland, minimal use flags and openrc on all these systems (other than systemd on arch).

Now I know that caching and memory allocation exists but how does it work? For example I noticed that ram usage spikes when starting the system and then gets lower with time (if doing nothing).
Is more RAM getting allocated if you have more system RAM available?
Also do optimizations such as -O3 -lto and other aggressive CFLAGS increase ram usage?

And yes I'm aware that less ram usage =/= better but it's fun to look at fastfetch and see only 200MB ram usage in idle (tty).
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9804
Location: almost Mile High in the USA

PostPosted: Sun Oct 20, 2024 9:54 pm    Post subject: Reply with quote

compare software versions including kernel, which has a great affect on memory usage especially if security options are enabled.
compare init scripts loading in files into cache that are subsequently unneeded later during boot
compare compile optimizations and configuration flags, usually -O3 uses more text RAM and -Os less. It will not affect runtime/stack/heap usage where glibc/kernel/software versions could.
compare how much ram you have (more memory you have, more page table memory needed)
compare drivers/hardware used (using a Trident card will use less memory than an nVidia).

I don't even care anymore on PCs until I actually run out of RAM, and inter-distribution comparisons are virtually worthless. Most of the time the memory is used to improve my experience (things like udisks/elogind/polkit and automount...saves me a manual step of manually mounting) and that's worth the RAM especially if it's not being used -- again unused ram is wasted ram.
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4985
Location: Bavaria

PostPosted: Sun Oct 20, 2024 11:27 pm    Post subject: Reply with quote

Maybe you are interested in "Tutorial: Linux Memory Management and Containers - Gerlof Langeveld, AT Computing"
https://www.youtube.com/watch?v=ql1axx--8sI
(dont worry, the first part is not about containers; you will also see "atop -B" ;-) )
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3818

PostPosted: Sun Oct 20, 2024 11:54 pm    Post subject: Re: How does RAM usage work? Reply with quote

L1NTHALO wrote:
Is more RAM getting allocated if you have more system RAM available?

Not to my knowledge.
L1NTHALO wrote:
Also do optimizations such as -O3 -lto and other aggressive CFLAGS increase ram usage?
-O3 should be expected to.
-lto shouldn't, binary size wise. There are counter examples though:
Code:
app-accessibility/speech-dispatcher
app-admin/gkrellm
app-admin/pwgen
app-admin/testdisk
app-arch/cabextract
app-arch/gnome-autoar
app-arch/rpm2targz
app-arch/wimlib
app-cdr/cdemu-daemon
app-crypt/libsecret
app-crypt/minisign
app-crypt/seahorse
app-editors/emacs
app-emulation/dynamips
app-misc/cmatrix
app-misc/symlinks
app-misc/tmux
app-office/dia
app-portage/ufed
app-shells/bash
app-text/liblangtag
app-text/mandoc
app-text/mythes
app-text/stardict
app-text/unpaper
dev-build/libtool
dev-build/make
dev-cpp/libmcpp
dev-db/pgmodeler
dev-db/postgresql
dev-lang/crystal
dev-lang/duktape
dev-lang/julia
dev-lang/luajit
dev-lang/mujs
dev-lang/nasm
dev-lang/R
dev-lang/ruby
dev-lang/swig
dev-libs/appstream-glib
dev-libs/blake3
dev-libs/check
dev-libs/crossguid
dev-libs/editline
dev-libs/fribidi
dev-libs/gdl
dev-libs/hts_engine
dev-libs/iniparser
dev-libs/level-zero
dev-libs/libassuan
dev-libs/libclthreads
dev-libs/libconfig
dev-libs/libdaemon
dev-libs/libedit
dev-libs/libgrapheme
dev-libs/libical
dev-libs/libpcre2
dev-libs/libscfg
dev-libs/libtasn1
dev-libs/libtpms
dev-libs/libuv
dev-libs/libvterm
dev-libs/libx86
dev-libs/libx86emu
dev-libs/libxml2
dev-libs/libxmlb
dev-libs/libzip
dev-libs/nsgenbind
dev-libs/nss
dev-libs/pugixml
dev-lisp/clisp
dev-python/aiohttp
dev-python/cython
dev-python/dbus-python
dev-python/lxml
dev-python/mpi4py
dev-python/msgpack
dev-python/pandas
dev-python/pyyaml
dev-qt/qttools
dev-scheme/gambit
dev-util/boost-build
dev-util/dialog
dev-util/geany-plugins
dev-util/premake:5
dev-util/premake
dev-util/radare2
dev-util/source-highlight
dev-util/trace-cmd
games-arcade/opensonic
games-board/cgoban
games-board/gnugo
games-engines/box2d
gnome-base/dconf-editor
gnome-extra/zenity
gui-apps/grim
gui-apps/gtklock
gui-apps/swayidle
gui-apps/wlr-randr
gui-apps/wlr-randr
gui-apps/wmenu
gui-apps/wofi
kde-frameworks/frameworkintegration
kde-plasma/kgamma
lxde-base/lxappearance
lxde-base/lxpanel
mail-filter/libmilter
media-gfx/gimp
media-gfx/sane-frontends
media-libs/alsa-lib
media-libs/babl
media-libs/fontconfig
media-libs/leptonica
media-libs/libbs2b
media-libs/libcdr
media-libs/libepoxy
media-libs/libid3tag
media-libs/lilv
media-libs/mesa
media-libs/tiff
media-libs/zita-resampler
media-plugins/g2reverb
media-plugins/vamp-libxtract-plugins
media-sound/asunder
media-sound/cdparanoia
media-sound/pipewire-module-xrdp
media-sound/yoshimi
media-video/ffmpeg
media-video/mpv
media-video/wireplumber
net-analyzer/rrdtool
net-analyzer/tcpdump
net-dns/avahi
net-dns/bind-tools
net-firewall/conntrack-tools
net-firewall/nftables
net-irc/hexchat
net-libs/libdom
net-libs/libpcap
net-libs/libssh2
net-libs/mbedtls
net-misc/remmina
net-misc/ubridge
net-proxy/privoxy
net-vpn/tor
net-vpn/wireguard-tools
sci-libs/alglib
sci-libs/arpack
sci-libs/colamd
sci-libs/lapack
sci-libs/lmfit
sci-libs/openblas
dev-python/scikit-learn
sci-libs/symmetrica
sci-mathematics/gap
sci-mathematics/sagemath-meataxe
sci-mathematics/surface-dynamics
sys-apps/dmidecode
sys-apps/file
sys-apps/gawk
sys-apps/haveged
sys-apps/iproute2
sys-apps/keyutils
sys-auth/nss-myhostname
sys-boot/syslinux
sys-cluster/libqb
sys-devel/bmake
sys-devel/llvm:15
sys-libs/libosinfo
sys-libs/readline
sys-libs/zlib
sys-process/htop
www-client/lynx
www-client/nyxt
www-servers/apache
x11-apps/xconsole
x11-apps/xlsfonts
x11-apps/xmodmap
x11-apps/xprop
x11-libs/gdk-pixbuf
x11-libs/gtk+:2
x11-libs/libclxclient
x11-libs/libfontenc
x11-libs/libICE
x11-libs/libXau
x11-libs/libxcb
x11-libs/libXcursor
x11-libs/libXrandr
x11-libs/libXxf86dga
x11-libs/pixman
x11-libs/xcb-util
x11-misc/i3status4
x11-misc/light-locker
x11-misc/obconf
x11-misc/pcmanfm
x11-misc/rofi
x11-misc/tint2
x11-misc/wmctrl
x11-misc/xdotool
x11-misc/xsel
x11-plugins/docker
x11-plugins/wmtimer
x11-terms/sakura
x11-wm/openbox
xfce-base/libxfce4util


From a minimalistic pov, Hyprland is quite ram hungry here, compared to other non KDE/GNOME wayland desktop env.

Thks 4 ur attention, interest & support.
_________________
USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9804
Location: almost Mile High in the USA

PostPosted: Mon Oct 21, 2024 5:31 am    Post subject: Re: How does RAM usage work? Reply with quote

L1NTHALO wrote:
Is more RAM getting allocated if you have more system RAM available?

Again the answer is YES. About 0.1%*x (for tables) + log(x) (for directories) of RAM is used up for page tables, so the more RAM you have, the more ram is used for keeping track. So a 64GiB machine will use up 64MiB plus directories of RAM -- for just page tables.
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum