# Memory usage - am I making another mistake?

**URL:** <https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265>\
**Category:** General\
**Created:** [3 March 2022 05:36 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265 "2022-03-03T05:36:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 March 2022 05:36 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/1 "2022-03-03T05:36:16Z")

</div>

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

I am seeing this message:

```auto
{"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:

```auto
[{"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...

 ![Screenshot from 2022-03-03 16-46-10](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/0/503213b9528c276993ab2d0d6fa9d07f65a74dda.png)

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.

---

<div class="post-metadata">

**Author:** ![nico25](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@nico25](https://discourse.nodered.org/u/nico25)\
**Post date:** [3 March 2022 07:34 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/2 "2022-03-03T07:34:32Z")

</div>

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

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/e/ae91479ddd1497ea16769fe476c29cc43958a0f6.png)

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

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 March 2022 07:36 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/3 "2022-03-03T07:36:05Z")

</div>

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

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/8/98a42c150523099d6d093cffcef3583966ef2387.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [3 March 2022 07:54 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/4 "2022-03-03T07:54:01Z")

</div>

What does `top` show for memory?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 March 2022 07:56 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/5 "2022-03-03T07:56:10Z")

</div>

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

 ![Screenshot from 2022-03-03 18-55-11](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/4/c4e7fa49cd95e2c7c56e4e0eb42f169637eae196.png)

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

And then there is this also...

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

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [3 March 2022 08:59 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/6 "2022-03-03T08:59:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 March 2022 09:03 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/7 "2022-03-03T09:03:24Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [3 March 2022 09:14 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/8 "2022-03-03T09:14:27Z")

</div>

> [@Trying\_to\_learn](#):
>
> So the node returning the _memory usage_ is a bit tainted in what it gives me

I have no idea what that figure represents.

> [@Trying\_to\_learn](#):
>
> How do I go about reducing the 500Meg buffer you mentioned

Why?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 March 2022 09:17 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/9 "2022-03-03T09:17:23Z")

</div>

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) 😉

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [3 March 2022 09:22 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/10 "2022-03-03T09:22:36Z")

</div>

> [@Trying\_to\_learn](#):
>
> wouldn't it be better to give the O/S a bit more usable ram?

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.

> [@Trying\_to\_learn](#):
>
> All my machines have been running for a long time with _SFA_ memory available (allegedly)

What does `top` show for one of those?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 March 2022 09:27 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/11 "2022-03-03T09:27:14Z")

</div>

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+

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [3 March 2022 09:28 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/12 "2022-03-03T09:28:15Z")

</div>

> [@Trying\_to\_learn](#):
>
> memory usage is pegged out at `93%`

What does `top` show for that?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 March 2022 09:31 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/13 "2022-03-03T09:31:40Z")

</div>

Ok, screen shots:

![Screenshot from 2022-03-03 20-27-38](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/d/addab69a94eb36705318d6554647a2eb9dbc48e1.png)

`top` yields

```auto
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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/b/abe6c5fe34ae866a2ec74d91a68aaeb7ba6ac26a.png)

RasPi 3B (No WiFi)  
Buster

`top` yields

```auto
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 

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [3 March 2022 09:37 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/14 "2022-03-03T09:37:27Z")

</div>

> [@Trying\_to\_learn](#):
>
> `522.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.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 March 2022 09:40 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/15 "2022-03-03T09:40:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nico25](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@nico25](https://discourse.nodered.org/u/nico25)\
**Post date:** [3 March 2022 11:36 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/16 "2022-03-03T11:36:05Z")

</div>

Maybe this will help you for your purpose:

[https://flows.nodered.org/node/node-red-contrib-os](https://flows.nodered.org/node/node-red-contrib-os)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 March 2022 11:36 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/17 "2022-03-03T11:36:37Z")

</div>

That's the one I am using. Sorry.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [3 March 2022 11:53 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/18 "2022-03-03T11:53:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 March 2022 12:06 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/19 "2022-03-03T12:06:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [3 March 2022 12:09 UTC](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265/20 "2022-03-03T12:09:32Z")

</div>

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

[Next page](https://discourse.nodered.org/t/memory-usage-am-i-making-another-mistake/59265.md?page=2)
