Node-Red on RPi restarts after ~2 weeks

Interseting. I didnt consider it might be due to excessive context usage in the schedules. There might be something in it.

You can of course modify your flows to remove the context inside cron nodes to see if it helps (and it should remove the need to re-write all your flows: instead, just update the cron entries to send a string & add a link call after the cron node)

[{"id":"f575aa0996438761","type":"cronplus","z":"07f7c6534787ceb5","name":"Daten","outputField":"payload","timeZone":"","storeName":"","commandResponseMsgOutput":"output1","defaultLocation":"","defaultLocationType":"default","outputs":1,"options":[{"name":"Modus","topic":"Modus","payloadType":"str","payload":"global.openwbModus","expressionType":"cron","expression":"*/5 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"Überschuss","topic":"U","payloadType":"str","payload":"global.Übers-ohne-LP","expressionType":"cron","expression":"*/5 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"Offset","topic":"offset","payloadType":"str","payload":"flow.offset","expressionType":"cron","expression":"*/5 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"Sofort","topic":"sofort","payloadType":"str","payload":"flow.sofort","expressionType":"cron","expression":"*/5 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"min I","topic":"minI","payloadType":"str","payload":"minI.minI","expressionType":"cron","expression":"*/5 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"frc","topic":"frc","payloadType":"str","payload":"flow.frc","expressionType":"cron","expression":"*/5 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"go-e","topic":"goe","payloadType":"str","payload":"global.LP2-Leistung","expressionType":"cron","expression":"*/5 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"Tibber","topic":"Tibber","payloadType":"str","payload":"flow.Tibber","expressionType":"cron","expression":"*/5 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"I max","topic":"Imax","payloadType":"str","payload":"global.Imax","expressionType":"cron","expression":"*/5 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"Phasen","topic":"phasig","payloadType":"str","payload":"flow.Phasen","expressionType":"cron","expression":"*/5 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":190,"y":800,"wires":[["d71a74992a2221a7"]]},{"id":"45417146841658f2","type":"cronplus","z":"07f7c6534787ceb5","name":"PV-laden","outputField":"payload","timeZone":"","storeName":"","commandResponseMsgOutput":"output1","defaultLocation":"","defaultLocationType":"default","outputs":1,"options":[{"name":"Überschuss","topic":"U","payloadType":"str","payload":"global.Übers-ohne-LP⌀","expressionType":"cron","expression":"*/10 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"PV-laden","topic":"PV","payloadType":"str","payload":"global.openwbModus","expressionType":"cron","expression":"*/10 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"SoC Freigabe","topic":"socfreigabe","payloadType":"str","payload":"global.socfreigabe","expressionType":"cron","expression":"*/10 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"Start PV","topic":"start","payloadType":"str","payload":"global.startpv","expressionType":"cron","expression":"*/10 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":180,"y":720,"wires":[["0f19b84352baf3d4"]]},{"id":"0f19b84352baf3d4","type":"link call","z":"07f7c6534787ceb5","name":"","links":["038f99a129522068"],"linkType":"static","timeout":"30","x":350,"y":720,"wires":[["4d722c16038484a9"]]},{"id":"4d722c16038484a9","type":"debug","z":"07f7c6534787ceb5","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":560,"y":720,"wires":[]},{"id":"d71a74992a2221a7","type":"link call","z":"07f7c6534787ceb5","name":"","links":["038f99a129522068"],"linkType":"static","timeout":"30","x":370,"y":800,"wires":[["30d93c12515df1e3"]]},{"id":"30d93c12515df1e3","type":"debug","z":"07f7c6534787ceb5","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":560,"y":800,"wires":[]},{"id":"2eb12067f62c3576","type":"group","z":"07f7c6534787ceb5","name":"Load context when payload is flow.xxx or global.xxx","style":{"label":true},"nodes":["6fc4e3b8eb2dcd58","038f99a129522068","36beb2ac4471eba6","d63e39946820db0a"],"x":164,"y":879,"w":462,"h":82},{"id":"6fc4e3b8eb2dcd58","type":"function","z":"07f7c6534787ceb5","g":"2eb12067f62c3576","name":"get context data","func":"\nif (typeof msg.payload === \"string\" && msg.payload.startsWith('flow.') && msg.payload.startsWith('global.')) {\n    const [store, key] = msg.payload.split('.')\n    if(store === 'flow') {\n        msg.payload = flow.get(key)\n    } else {\n        msg.payload = global.get(key)\n    }\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":920,"wires":[["36beb2ac4471eba6"]]},{"id":"038f99a129522068","type":"link in","z":"07f7c6534787ceb5","g":"2eb12067f62c3576","name":"load context","links":[],"x":205,"y":920,"wires":[["6fc4e3b8eb2dcd58"]]},{"id":"36beb2ac4471eba6","type":"link out","z":"07f7c6534787ceb5","g":"2eb12067f62c3576","name":"link out 1","mode":"link","links":[],"x":585,"y":920,"wires":[]},{"id":"d63e39946820db0a","type":"change","z":"07f7c6534787ceb5","g":"2eb12067f62c3576","name":"lösche","rules":[{"t":"delete","p":"cronplus","pt":"msg"},{"t":"delete","p":"scheduledEvent","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":920,"wires":[[]]}]

I am interested to see if that improves matters.

Would you be willing to give this a go on one of your systems?

I don't understand your process, I think it´s complicated and I don't like that!
I´ve rebuild my flow with injects and I´ll wait a few weeks, if the memory problem is gone or not.

what I don’t quite understand is my other node-red main instance on a virtual machine (x64, much more power than a RPi, with 4gb ram), it has several cronplus nodes too, here I can´t see memory rising over time.
does it have to do with the processor/architecture x64 <-> arm?

I'm guessing you haven't learned about the link-call. Its akin to a subroutine and will help I'm many situations to reduce code duplication. It's actually a simplification in most cases.

If you're not interested in learning, that's ok too

the cronplus were not guilty, NR starts without them wich much less ram (10%).
but after some days ram rise and rise, after 8 days it is at 30%.
and the cpu spikes begin after a few days also:

on my VM (with a much bigger flow and 4GB ram) I replaced some cronplus with injects too, here the ram decreases from 9 to 7% and stays at 7%.

So the cronplus needs some ram I leared.
I am still at a loss.

the main work (every 5s for both charging stations) comes from this:

[{"id":"b589034db714acd4","type":"inject","z":"5f6e5e5e2b5d2c03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"Modus","payload":"openwbModus","payloadType":"global","x":140,"y":1500,"wires":[["9fd0cc29df201ca8"]]},{"id":"e66fe4538a4e1c67","type":"inject","z":"5f6e5e5e2b5d2c03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"U","payload":"Übers-ohne-LP","payloadType":"global","x":150,"y":1860,"wires":[["9fd0cc29df201ca8"]]},{"id":"1000fd713681e6fa","type":"inject","z":"5f6e5e5e2b5d2c03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"offset","payload":"offset","payloadType":"global","x":120,"y":1740,"wires":[["9fd0cc29df201ca8"]]},{"id":"f2ae7da003be0761","type":"inject","z":"5f6e5e5e2b5d2c03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"sofort","payload":"sofort","payloadType":"flow","x":110,"y":1540,"wires":[["9fd0cc29df201ca8"]]},{"id":"9e41a8bd4d47fcaf","type":"inject","z":"5f6e5e5e2b5d2c03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"minI","payload":"minI","payloadType":"flow","x":100,"y":1580,"wires":[["9fd0cc29df201ca8"]]},{"id":"3bc782447a157170","type":"inject","z":"5f6e5e5e2b5d2c03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"frc","payload":"frc","payloadType":"flow","x":100,"y":1620,"wires":[["9fd0cc29df201ca8"]]},{"id":"ed24451bab056934","type":"inject","z":"5f6e5e5e2b5d2c03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"goe","payload":"LP2-Leistung","payloadType":"global","x":140,"y":1820,"wires":[["9fd0cc29df201ca8"]]},{"id":"d5f9ca8f20ca7895","type":"inject","z":"5f6e5e5e2b5d2c03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"Tibber","payload":"Tibber","payloadType":"flow","x":110,"y":1660,"wires":[["9fd0cc29df201ca8"]]},{"id":"679a152be4daea2b","type":"inject","z":"5f6e5e5e2b5d2c03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"Imax","payload":"Imax","payloadType":"global","x":110,"y":1700,"wires":[["9fd0cc29df201ca8"]]},{"id":"d807bd297545e9e3","type":"inject","z":"5f6e5e5e2b5d2c03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"phasig","payload":"Phasen","payloadType":"flow","x":120,"y":1780,"wires":[["9fd0cc29df201ca8"]]},{"id":"9fd0cc29df201ca8","type":"join","z":"5f6e5e5e2b5d2c03","name":"Objekt","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"10","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":480,"y":1700,"wires":[["42ffd193789a6062","abd526164e81f3dc"]]},{"id":"42ffd193789a6062","type":"switch","z":"5f6e5e5e2b5d2c03","name":"Modus","property":"payload.Modus","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"num"},{"t":"eq","v":"4","vt":"num"}],"checkall":"true","repair":false,"outputs":5,"x":470,"y":1580,"wires":[["e797fb53d8ef5a6b"],["99dcad8344c3dac9"],["fc6a7b5f6e5f9d96"],["aa7ca45d0867c8e4"],["3dca937338b4bd4c"]]},{"id":"e797fb53d8ef5a6b","type":"change","z":"5f6e5e5e2b5d2c03","name":"aus","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"},{"t":"set","p":"topic","pt":"msg","to":"Stromvorgabe","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":1500,"wires":[["160bb8af94c2bbfe"]]},{"id":"99dcad8344c3dac9","type":"function","z":"5f6e5e5e2b5d2c03","name":"PV","func":"let U = msg.payload.U;\nlet ph = msg.payload.phasig;\nlet O = msg.payload.offset;\nlet frc = msg.payload.frc;\nlet goe = msg.payload.goe;\nlet T;\nif (goe > 1000) {\n    T = 0.5;\n    O = O /2;\n}\nelse {\n    T = 1;\n}\nlet I;\nI = (U*T + O) / ph / 230;\nI = Math.floor(I);\nif (I < 6) {\n    I = 6;\n}\nif (I > 16 && ph >= 2) {\n    I = 16;\n}\nelse if (I > 22) {\n    I = 22;\n}\nif (frc == 1) {\n    I = 0;\n}\nmsg.payload = I;\nmsg.topic = \"Stromvorgabe\";\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":1540,"wires":[["160bb8af94c2bbfe"]]},{"id":"fc6a7b5f6e5f9d96","type":"function","z":"5f6e5e5e2b5d2c03","name":"min+PV","func":"let U = msg.payload.U;\nlet ph = msg.payload.phasig;\nlet O = msg.payload.offset;\nlet min = msg.payload.minI;\nlet frc = msg.payload.frc;\nlet goe = msg.payload.goe;\nlet T;\nif (goe > 1000) {\n    T = 0.5;\n    O = O /2;\n}\nelse {\n    T = 1;\n}\nlet I;\nI = (U*T + O) / ph / 230;\nI = Math.floor(I);\nif (I < min) {\n    I = min;\n}\nif (I > 16 && ph >= 2) {\n    I = 16;\n}\nelse if (I > 22) {\n    I = 22;\n}\nif (frc == 1) {\n    I = 0;\n}\nmsg.payload = I;\nmsg.topic = \"Stromvorgabe\";\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":720,"y":1580,"wires":[["160bb8af94c2bbfe"]]},{"id":"aa7ca45d0867c8e4","type":"function","z":"5f6e5e5e2b5d2c03","name":"Sofort","func":"let Imax = msg.payload.Imax;\nlet sofort = msg.payload.sofort;\nlet I;\nif (sofort <= Imax) {\n    I = sofort;\n} else {\n    I = Imax;\n}\nif (I < 6) {\n    I = 6;\n}\nmsg.payload = I;\nmsg.topic = \"Stromvorgabe\";\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":1620,"wires":[["160bb8af94c2bbfe"]]},{"id":"3dca937338b4bd4c","type":"function","z":"5f6e5e5e2b5d2c03","name":"Tibber","func":"let Imax = msg.payload.Imax;\nlet sofort = msg.payload.sofort;\nlet Tibber = msg.payload.Tibber;\nlet I;\nif (sofort <= Imax) {\n    I = sofort;\n} \nelse {\n    I = Imax;\n}\nif (I < 6) {\n    I = 6;\n}\nif (Tibber == 0) {\n    I = 0;\n}\nmsg.payload = I;\nmsg.topic = \"Stromvorgabe\";\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":1660,"wires":[["160bb8af94c2bbfe"]]},{"id":"160bb8af94c2bbfe","type":"rbe","z":"5f6e5e5e2b5d2c03","name":"nur Änderung","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1000,"y":1620,"wires":[["01ef531eba669974","5970b8631502e323"]]},{"id":"5970b8631502e323","type":"change","z":"5f6e5e5e2b5d2c03","name":"global.Strom","rules":[{"t":"set","p":"Strom","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":990,"y":1580,"wires":[[]]}]

maybe somebody could take a look if there is anythink strange, which could rise ram infinite.

last idea:
I named a global to global.Übers-ohne-LP⌀
could the "⌀" cause memory rising?

Might be of interest: Node-red + MCP23017 (x5) slowing down - #27 by TadyTheFish

Hello .. sorry for butting in :slight_smile: my problem was reading CPU and memory stats. It slowed down NR very much after 24h but it never restarted and memory didn't get this high

That's fine, your input is welcome.

Just pointing out correlation for @Becker - could be something in it. for example, if he is running these nodes more frequently than you were, it may be the cause or a contributor to it (i.e. a piece of the puzzle)

1 Like

I can participate no problem. OP can you tell me what is NR doing? I saw that charts were already mentioned ( I had problems with them so I used Grafana and used a template node)
If I understand you correctly you are pooling some data very frequently?

Could log level "trace" or "debug" help me ?