# Memory leak ?... trouble performance now

**URL:** <https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119>\
**Category:** General\
**Created:** [13 December 2021 11:58 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119 "2021-12-13T11:58:31Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [13 December 2021 11:58 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/1 "2021-12-13T11:58:31Z")

</div>

When I first started with Node-red. I had trouble with memory leak, but after 1 or 2 months, it disappeared.  
Now for as long as 2 months, I have the same issue again. But my application works fine, so far.  
Every now and then the memory hit some 95%, and then resets to about 50 to 55 % and then builds up again slowly. If I restart Node-red or reboot RPI, it also drops again.  
Today I did some minor chages, and now the memory will not go lower then about 85% and is very fast over 90%. Als the CPU is working like crazy and temp has gone up from about 32 dgrC to 47 dgrC.

Most of my application exist of some fast modbus connections and some slow http requests. Data saved to influxDB and some graphs and tables. Nothing special I would think. The Node-red log looks fine.

Anyone has any idea where to look for the cause ????

Here is some info,

![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/d/8d527cc14141d6df0b11d0ed6d44b5fb4993c9ff.png)

 ![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/a/ba129a82a4de89e469ab31ed91f633fd76a8f6b9.png)

![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/f/ff6d1359b11bda9aae53646869cd596fd5e9e4e0.png)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [13 December 2021 12:16 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/2 "2021-12-13T12:16:59Z")

</div>

In a terminal run **htop** to see which applications are hogging the memory.

---

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [13 December 2021 12:20 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/3 "2021-12-13T12:20:12Z")

</div>

@jbudd Here is the output of **htop** , but so far I can only see that Node-red is the cause.

 ![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/1/41bd6ec3ca6cd2dda300b21e6005b1a0d16957cd.png)

 ![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/d/edf311432c09f558031f6ad59e263c4ce6266beb.png)

---

<div class="post-metadata">

**Author:** ![ozpos](https://avatars.discourse-cdn.com/v4/letter/o/278dde/32.png) [@ozpos](https://discourse.nodered.org/u/ozpos)\
**Post date:** [13 December 2021 12:22 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/4 "2021-12-13T12:22:23Z")

</div>

Check that charts and displayed tables do not hold an unnecessary number of points and that you have implemented a retention policy.

---

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [13 December 2021 12:29 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/5 "2021-12-13T12:29:06Z")

</div>

@ozpos and @jbudd , I have killed all access to influxDB. usage is back to 7% again.  
But memory is still very high, about 78%.

---

<div class="post-metadata">

**Author:** ![ozpos](https://avatars.discourse-cdn.com/v4/letter/o/278dde/32.png) [@ozpos](https://discourse.nodered.org/u/ozpos)\
**Post date:** [13 December 2021 12:32 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/6 "2021-12-13T12:32:56Z")

</div>

Have you added any new nodes ? I have found that with a Pi Zero some nodes pull in huge amount of js.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [13 December 2021 12:34 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/7 "2021-12-13T12:34:12Z")

</div>

> [@henkkas](#):
>
> I can only see that Node-red is the cause.

Influx is using most CPU time, Node-Red using most memory.  
Is it a Pi 3B? Only 1GB memory?

I wonder if you have accidentally created a loop in Node-Red.

Try disabling all the flows and watch memory usage as you reneable them one by one.

---

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [13 December 2021 12:35 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/8 "2021-12-13T12:35:16Z")

</div>

@ozpos , No I didn't lateley, only simple gate, but this was working fine up till about 2 houres ago.  
Like I said, did only minor changes.

---

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [13 December 2021 12:46 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/9 "2021-12-13T12:46:16Z")

</div>

@jbud Indeed influx has been killed, but restored all write actions again. No problem with performance so far.  
It is an RPI 3B+ with 1 GB memory , yes.

I will try that, and see where it is coming from.

---

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [13 December 2021 13:01 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/10 "2021-12-13T13:01:41Z")

</div>

@jbudd , I disabled almost all flows. But memory still high,

![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/6/9638c5548bacdad1aafc4067003a990c544fa5e4.png)

 ![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/4/c420327c6d77e0d4e66499f079122745a5d15aa3.png)

---

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [13 December 2021 14:25 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/11 "2021-12-13T14:25:41Z")

</div>

@jbudd , I restored all flows again. Performance is still rather good(usage and temp.) But memory still slow on the rise.Very strange where bad performance came from.......  
Any other ideas where I can find where the memory build up comes from?

 ![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/2/52c3f03677a9831817629652c00cf9388f153e6d.png)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [13 December 2021 15:10 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/12 "2021-12-13T15:10:11Z")

</div>

Not really. Is influx still disabled?

I think there are discussions here about profiling and debug tools, I've not used them.

---

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [13 December 2021 15:17 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/13 "2021-12-13T15:17:39Z")

</div>

@jbudd No almost everything is back running again. Only a test flow I have disabled.

---

<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:** [13 December 2021 15:39 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/14 "2021-12-13T15:39:26Z")

</div>

Don't worry about the memory for the moment, the main problem is the CPU usage. Possibly you have some sort of loop in the system. Or it could be influx. Does the CPU drop right down if you stop influx?

---

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [13 December 2021 16:03 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/15 "2021-12-13T16:03:29Z")

</div>

@Colin and @jbudd . Yes, already found a loop, just now, on feedback to multi switch.

That is not the issue anymore. Still the memory is high, and won't go down anymore like it did before.

![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/b/6b37118aab1cb31980b52a7968539f337181f873.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:** [13 December 2021 16:41 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/16 "2021-12-13T16:41:10Z")

</div>

Can you show us what `top` shows please?

---

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [13 December 2021 16:44 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/17 "2021-12-13T16:44:11Z")

</div>

@Colin

 ![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/a/8a1e4085dd99af71ad9f21f579fc1a1bcf9d9ec9.png)

 ![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/3/e32aa96b15b094ae9ff97694b8f9f35cb36f1078.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:** [13 December 2021 17:17 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/18 "2021-12-13T17:17:49Z")

</div>

I don't see any problem there. Linux tries to make best use of all the memory there is, keeping disc buffers in RAM and caching stuff where possible. To get actual amount of memory available for use you have to look at the mem available figure. Node red is only using 17% of the ram.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [13 December 2021 17:39 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/19 "2021-12-13T17:39:54Z")

</div>

Probably not related to your recent problems but certainly do look at InfluxDB and make certain that you have a retention policy in place for any detailed data. On your Pi, eventually you will start to get CPU spikes and SWAP use.

Try to keep detailed records only for a limited time. Typically I keep 1 minute records for 7 days but I have a continuous query that creates hourly records of everything in the 7 day store (keeping avg, max and min values over the hour for all values in the detailed store). I keep the hourly record for 5 years.

---

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [13 December 2021 19:18 UTC](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119/20 "2021-12-13T19:18:44Z")

</div>

@Colin . Thanks. Yes, I can see also, that node-red is in fact only using 17 - 18% of the total memory it shows in TOP. Why dos it say in Node-red that it uses almost all of 924 MB available? Is there a way to increase mem available for Node-red?

![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/4/74bacc26284836527200a8fc09662a63030443ea.png)

[Next page](https://discourse.nodered.org/t/memory-leak-trouble-performance-now/55119.md?page=2)
