Node red crashes after ~1h "heap out of memory"

Hello team!
My node red clashes after few hours of use. Here below is an image of the message display anytime it clashes.

.
Any idea on what could be the cause of this failure, please….
Thanks in advance

In future, if possible, please copy/paste logs rather than an image.

As it says, you have an error in your sql syntax in the node ReadFromDatabase. Probably the invalid message sent by that node is confusing the flow after it and causing the out of memory error and the crash.

I suggest removing the wire out of the sql node so that it won't attempt to use the output of that node and then work out what is wrong with your sql.

I will remove the node-red-dashboard tag from your message as it is nothing to do with the dashboard.

Thank you Colin!
I’ve check the node and corrected it. But it still crashes and displays the same error message

.

Did you see my previous comment?

If it is still happening then you have something in your flows that is using up all the memory.
Did this start happening after a change you made? If so then roll back that change to see if it is fixed.

Also can you show us the start of the node-red startup output please.

What versions of Node-red and Node.js are you running?
Does the error occur immediately when Node-red starts up, or when a particular flow is active, or after a few/many messages have been processed?
Is SQL working on a massive data set?

Node red version 4.0.9
Node.js v23.9.0.
It usually crashes after an hour of running. It pull data from control modules per second, process and save them to the sql database

Node 23 is not supported, you should use an lts version. Goo back to 22

Here is node-red startup output ```23 Jul 21:56:47 - [info]

Welcome to Node-RED

23 Jul 21:56:47 - [info] Node-RED version: v4.0.9
23 Jul 21:56:47 - [info] Node.js version: v23.9.0
23 Jul 21:56:47 - [info] Windows_NT 10.0.22621 x64 LE
23 Jul 21:56:48 - [info] Loading palette nodes
23 Jul 21:56:48 - [info] Dashboard version 3.6.5 started at /SCADA
23 Jul 21:56:49 - [info] Settings file : C:\Users\ENEO.node-red\settings.js
23 Jul 21:56:49 - [info] Context store : 'default' [module=memory]
23 Jul 21:56:49 - [info] User directory : \Users\ENEO.node-red
23 Jul 21:56:49 - [warn] Projects disabled : editorTheme.projects.enabled=false
23 Jul 21:56:49 - [info] Flows file : \Users\ENEO.node-red\flows.json
23 Jul 21:56:49 - [info] Server now running at http://127.0.0.1:1995/
23 Jul 21:56:49 - [warn]


Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.

23 Jul 21:56:49 - [warn] Encrypted credentials not found
23 Jul 21:56:49 - [info] Starting flows
23 Jul 21:56:49 - [info] Started flows
23 Jul 21:56:49 - [info] [sqlitedb:d742df861f936882] opened C:\ENEO\BASEDEDONNEES.db ok

I’ve gone back to lts v22 but still facing the same problem. It is possible to write a code that checks if my node red is running or not and then start it if not already running?

Run it as a service and it will auto restart.

NOTE: This is not addressing the real problem.

You are probably creating backpressure which is exhausting memory. Unless you share more details (like flows and details of what is happening when) it will be hard to advise the correct approach

I have another similar project that I installed since last year, I haven’t experienced any crashes. The project functions in the same way but data are only save to the database after every 5 minutes whereas in this other project, it is after every 1 second. I’m guessing the problem lies with the frequency. I’ve reduced it to 10 minutes and it’s still under observation. I’ll send you the flows