Memory usage - am I making another mistake?

I've just replaced an older RasPi with a new one.

I am seeing this message:

{"totalmem":968056832,"freemem":88260608,"memusage":90.88}

When I break it down I see these values:

Total memory
968056832
Free memory
88260608

memusage
90.88

Um.... No. It is less than 10% used - yes?

Flow:

[{"id":"aa45973b.41cf78","type":"Memory","z":"e2bd5a4e.5597e8","name":"","x":1283,"y":434,"wires":[["c8ed4350.1299f8","b922e021.624b1"]]},{"id":"b922e021.624b1","type":"debug","z":"e2bd5a4e.5597e8","name":"Memory usage","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1450,"y":490,"wires":[]}]

Oh from the CLI...

I don't quite get that if the machine has 923MB of memory and it is using 371MB the bar is all the way to the right.

Well I ain´t even near 50% used and the bar is still in the middle.

I think it´s just not accurate. The used memory in htop should be accurate tho

1 Like

Ah, there are a lot of open cans of worms just now. :wink:

Oh, but what about the numbers in htop.

Looking at the numbers, the used is about 30% of the total.....

So why is the bar nearly all the way over to the right?

Screenshot from 2022-03-03 16-46-10

What does top show for memory?

Sorry, I had forgotten how confusing it is/was.

I don't know at what I am looking. (Sorry)

And then there is this also...

free -h
              total        used        free      shared  buff/cache   available
Mem:          923Mi       329Mi        59Mi        21Mi       533Mi       512Mi
Swap:          99Mi       5.0Mi        94Mi

I find top the easiest to understand (though my understanding may be flawed). It is saying that there is 923MiB total, of which 94 is unused and 500 is in use for temporary buffers and cache. A lot of that 500 can be released if necessary so though it is in use it is available if something needs it. Avail Mem is an estimate of the amount that can be made available if necessary, and is made up of the Free memory plus most of the buffers/cache. It is when Avail Mem gets low that you may get into difficulties, though then the OS will start moving stuff that is not regularly used into Swap. There is nothing wrong with a bit of Swap being used, the problem arises when the OS has to move regularly used stuff into swap and the system clogs up because it has to keep moving data in and out of swap.

2 Likes

So the node returning the memory usage is a bit tainted in what it gives me.

Though what you just said does explain a lot.

All my machines have been running for a long time with SFA memory available (allegedly).

The old 2B amazed me that it was surviving with nearly no memory left.

How do I go about reducing the 500Meg buffer you mentioned?

I have no idea what that figure represents.

Why?

I don't know. But wouldn't it be better to give the O/S a bit more usable ram?

Or should I leave well enough alone?

(If it isn't broken: fix it until it is) :wink:

The OS is making use of it, for buffers and cache. The OS tries to use as much memory as possible in order to make everything run smoothly. The normal situation with Linux is that most of the free memory is used by the OS for buffers and disc cache. As I said, if an application needs it then the OS will free it up and let the application have it. Provided the Avail Mem stays at a reasonable figure then you don't have anything to worry about.

What does top show for one of those?

Thanks.

Just something else - weirdish.

I'll leave one of the three alone as it is having a bit of a hissy fit just now.

I just checked the version of the os and updated it to 0.2.1. Now the graph is a lot less populated. 65% - down from about 93%

However: On the other machine the os node is 0.2.1 and the memory usage is pegged out at 93%.

One is a 3B and the other is a 3B+

What does top show for that?

Ok, screen shots:

Screenshot from 2022-03-03 20-27-38

top yields

pi@TelePi:~ $ top

top - 20:30:38 up 15 min,  3 users,  load average: 1.13, 0.98, 0.70
Tasks: 171 total,   1 running, 170 sleeping,   0 stopped,   0 zombie
%Cpu(s):  3.4 us,  8.1 sy,  0.0 ni, 88.3 id,  0.1 wa,  0.0 hi,  0.1 si,  0.0 st
MiB Mem :    871.7 total,    292.1 free,    290.3 used,    289.3 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.    522.8 avail Mem 

Just updated the os and the Memory went from 93% down to 65%.
RasPi 3B+ Buster.

Screenshot from 2022-03-03 20-27-45

RasPi 3B (No WiFi)
Buster

top yields

pi@BedPi:~ $ top

top - 20:31:29 up 25 days,  3:45,  3 users,  load average: 0.08, 0.16, 0.16
Tasks: 164 total,   1 running, 163 sleeping,   0 stopped,   0 zombie
%Cpu(s):  2.6 us,  9.5 sy,  0.0 ni, 87.1 id,  0.7 wa,  0.0 hi,  0.1 si,  0.0 st
MiB Mem :    924.2 total,     53.0 free,    388.6 used,    482.6 buff/cache
MiB Swap:   1024.0 total,    997.0 free,     27.0 used.    434.8 avail Mem 

You have loads of memory available. The figures that matter are Avail Mem and Swap used, you can ignore all the rest. Provided there is a reasonable amount of avail mem and swap is not large then there is no problem.

1 Like

Ok, I am looking at the wrong numbers.

Just it would be nice if the available (or free) was the number/s I wanted.

Ok, I won't (or: try not to) worry about it then.

Maybe this will help you for your purpose:

https://flows.nodered.org/node/node-red-contrib-os

That's the one I am using. Sorry.

Unfortunately that node does not appear to give you the most important number, which is Available Memory (as shown by top).

Oh well.... I'll maybe remove that from the GUI as it isn't really a valid number/value.

You could add an issue to the website asking for it to be added.