Unplanned Restart / Reboot?

Also, which version of nodejs are you using on this pi? If it is 13.x as in the other thread then the first thing you should do is to install a supported version (probably 12.x). It may not be the problem but until you check there is no way of knowing.

I believe @Gawan means the power supply. If the Pi has been up for 20 days, it most likely is not the power supply

Or did he/she mean that it is not running out of memory?

I'm not sure, but the error clearly says out of heap memory so regardless of it currently being at 20% memory use, that might still be the issue. Without more information that's hard to say.

You have a 1GiB RAM device and you are running something that requires Java that is consuming a LOT of CPU time CUxD also seems to be using a lot of CPU.

As your swap use is around 70% as well, that indicates that daemons are regularly swapping out of memory and back. In other words, you don't have enough memory to run the services you are running.

Here is the output from my poor old Pi3 running sudo htop sorted by mem%

Which should show you why I'm moving everything to a laptop at long last. This has 1GB of RAM but InfluxDB wants 2GiB of virtual memory and the Ubiquiti AP controller running under Java wants 1GiB.

As you can see, swap space is almost maxed out and the Pi keeps stalling. My own fault for letting the InfluxDB data grow too large. But JAVA always wants loads of memory and usually starts at 1G.

I can also see that Docker decided to restart itself. Poor old Pi, it will soon get a well earned rest though I'll probably continue to run Unifi on it since trying to run that under Debian 10 (Buster) is an exercise in futility right now (the usual issues with MongoDB).

I am using 400 MB of 1 GB Ram and 70% of the Swap File.
Is it possible to extend the Swap File ?

Or should I buy a new Raspi with more RAM ?

You could do either, but relying on swap is how you get your sd card broken the soonest. Most of the time your system just shouldn’t use so much unless you’re running applications not suited for it. In this case log4j is using about 25% of total memory, but node-red at 254 res once again suggests that there’s something in your flows creating it to use more and more memory over time. Which means going through your flow step by step to figure out what causes this. Are you by chances reading in files or creating/putting through large files? Or anything else that could cause a lit of memory usage

I am not relying on Swap, I would really prefer if the raspi would fill the RAM up to 100% ... skipping RAM
that should be possible already now ... 400+ MB RAM are free

the only thing I am doing that could request bigger amounts of memory, is a small number of charts (5+) filled with thousands of datapoints (24 hours ... datapoint every 5 min).
I am not working with files or media objects

edit: if I open the dashboard-website in my browser the browser RAM usage jumps from 550 MB to 650 MB. Thats just a very small indication on the RAM usage of these charts

The heap overflow noted in your error report means that something, somewhere in your setup is allocating memory and not releasing it. Over time, it uses more and more, until there is none left to allocate.

Adding more memory or increasing the swap space will like give you a longer time between crashes, but it won't fix the underlying problem.

Can you monitor memory use over time, and see what it looks like at regular intervals, up to the point at which it crashes? Some idea of the rate at which it's being allocated might be a clue to the cause.

The fact that it is using a large amount of swap generally indicates that at some point it was using a lot of RAM, though it is not now. That is not surprising since node red recently crashed because there was no free memory. As others have suggested, either node-red (or something else) is slowly accumulating memory till it fails or there is some particular occurrence that causes a sudden spike in memory.

What version of nodejs are you running on this pi?

nodejs 12.14.0

That should be ok.

Why not try disabling your charts and see what happens?

1 Like

Are you running this browser (and thus a desktop environment) on that same pi as well?

1 Like

Incidentally, using SWAP on a Pi isn't just a way to wear out the SD-Card rapidly, it is a disaster for performance as it has a double impact.

Firstly the SD-Card is desperately slow so the reading/writing to it slows the system to a crawl very quickly. The process also uses a lot of CPU.

You need to be realistic about what a Pi can actually do. If you want to run it as a server, don't run a desktop on it, disable that completely. If it is heavily hitting swap, time to buy a 2nd Pi and move some services over. Alternatively, you might consider one of the cheap micro-PC's that now are so common. These are massively faster than a Pi4 thanks to a more balanced architecture, including fast PCI and the ability to directly use a proper disk controller with SSD.

As I've said, I'm moving my 2 Pi's to an old (maybe 4-5 years old) laptop. The Pi's have served me well for about the same time but it is time to move on.

2 Likes

It happened only twice during the last week and its stable since two days now - so its not a huge issue for me, its basically something I would like to understand.

Nevertheless I am monitoring the RAM usage now and it seems to be quite stable at 500 MB.

Is there a possibility to deactivate SWAP-File usage at all ?
It does not make sense to use 77% of a 100MB SWAP-File while there are 400MB RAM free and available.

Edit:
Using another device instead of the RaspPi would lead to a much higher power consumption. I could as well put everything to my Synology NAS, but I like the idea of having one "IOT"-Raspi, doing all the necessary tasks

There may be lots of memory available now but at some point there wasn't, otherwise it would not have put all that stuff there. If you had swap disabled (your favourite search engine will tell you how I assume) then it would have failed earlier. There is no harm having swap enabled provided it is not using it regularly. Little (or never) used stuff will get put there and leave more RAM available. A pi I have that has been working fairly hard for three weeks has used 180MB of 1GB swap, but the amount has not changed since I checked it some hours ago so I know it is not a problem. Normally the device is on permanently and swap does not accumulate, I had a power fail three weeks ago so nothing has been on longer than that at the moment.

had another reboot at 12:57
RAM-Usage was around 450, Swap-File was at 75

now (after node-red reboot) RAM is at 253 (of 900), Swap is at 77.3

Raspi did not reboot ... just Node-Red

I think that everything has been said that can be. You have to simplify something.

Did you disable the desktop? Did you sanity check the charts on your Dashboard (no point in having more data points than you have pixels to display them, that chews through memory)?

1 Like