You are not logged in.

#1 2023-01-28 03:03:55

Paraclinical
Member
Registered: 2023-01-28
Posts: 2

Arch Linux shows wrong RAM usage.

Hello,

As i wrote in my title my installation shows the wrong RAM usage.

Anytime I open programs such as bpytop or glances my memory always sits at around 2GiB (7-8%), which is wrong from my understanding, when I manually add up all the resources used at idle it only comes out about 900-1000MiB, bear in mind im using Xorg, alacritty and i3 which are the programs that use the most on idle so it really shouldn't be 2GiB.

https://i.imgur.com/tnNtmTK.png
Here's the screenshot of my usage at idle. All processes combined together come out to be 1076MiB (Minus Flameshot 160MiB = 900MiB)

Which means the actual usage is about 1GiB, so why am I getting a 1GiB reading out of nothing, this is a newly built machine with Corsair Vengeange LPX RAM (32GiB). I use a fairly minimal install just like on my laptop, my laptop although shows the correct readings.

I would appreciate any insight in why am I shown wrong ram usage readings, Thanks.


Mod Edit - Replaced oversized image with link.
CoC - Pasting pictures and code

Last edited by Slithery (2023-01-28 07:51:47)

Offline

#2 2023-01-28 03:15:42

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: Arch Linux shows wrong RAM usage.

Paraclinical wrote:

All processes combined together come out to be 1076MiB

How do you get this number?  Did you actually add up values from all processes (including kernel processes) by hand?  That's A) beyond tedious, and B) compounding rounding error as you the monitoring tools you are referring to are not remotely precise enough for that kind of comparison.

Check with `free` or better yet the contents of /proc/meminfo.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2023-01-28 19:00:11

Paraclinical
Member
Registered: 2023-01-28
Posts: 2

Re: Arch Linux shows wrong RAM usage.

Hello,

Using the free -h command seems to bring out a more accurate ram usage.

               total        used        free      shared  buff/cache   available
Mem:            31Gi       841Mi        29Gi       1.0Mi       1.2Gi        30Gi
Swap:             0B          0B          0B

I tried comparing 3 different tools and their usages with the command and got this:

 free: 1.5Gi
 glances: 1.6Gi
 bpytop: 1.91Gi
 htop: 1.5Gi 

I know this seems very pedantic and not a big deal since I have 32GiB of RAM, im just curios how there's discrepancy between tools for such a simple task.
htop does seem to be the most accurate though, so I'll stick with using that.

Offline

#4 2023-01-28 19:17:32

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: Arch Linux shows wrong RAM usage.

I've never used glances or bpytop (and have never even heard of the latter), so I have no idea what they are doing or how they generate their values.  But there are quite a few reasons that reliable system monitors could give results that superficially look very different for RAM use.  The most common discrepancy is confusions between 2^10 units and 10^3 units (e.g., GiB vs GB) - many end users completly conflate these, but then so to many system monitor displays putting the wrong units.  On occasion it's even a mishmash as a "GB" display is calculated by the number of KiB/1000.  Though this should only contribute around 7% error in the range of GiB/GB.

Next there are different definitions of what memory is "free".  Just look at the various columns of the `free' output.  Which one(s) does the glances/bpytop result reflect?  You can even ask what the values provided by "free" represent as quite recently an update to the procps-ng package changed the way "free" calculates it's values.  I currently have "free" provided by procps-ng as well as a busybox-provided free, and the layout of their output is the same, but the values differ.  Now compound this example by the fact that /proc/meminfo has many more RAM-use-related metrics than are even used or displayed by free.

So I'd even question you're conclusion that htop is the most accurate.  What is that based on?  Your data indicates that htop and free are likely doing the same calculation, but is that the "right" one?  There really is no "right" one as it really depends on what you want to know about RAM use - the question "How much free RAM do I have?" is quite ambiguous, and so different tools can answer it differently (while still each being accurate).  There are a few ways of answering that question that are certainly misleading and therefore could be called wrong, but I there are still multiple different answers that could be called right.

Most metrics of available memory could be sufficient for a system monitor as for such use one often cares less about the precise usage at the moment but is rather monitoring for concerning usage conditions or drastic changes over time.  These conditions would be reflected equally well in any number of good calcuations for available memory.  If you want a tool to use for profiling a bit of code, or debugging some potential memory leak in a bit of software, then NO generic system monitor tool is valid; you need a much more fine-grained tool for that.

So your other premise that I'd question is that reporting available memory is "a simple task".  It's simple to do, but it's most definitely not a task with a simple singular answer.

Last edited by Trilby (2023-01-28 19:25:56)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB