node-red-nodes icon indicating copy to clipboard operation
node-red-nodes copied to clipboard

possible memory leak in ping node

Open andysc opened this issue 9 years ago • 12 comments

After a long time (weeks) of pinging every 15 seconds, Node-RED crashed with:

26 Jan 12:46:45 - [red] Uncaught Exception: 26 Jan 12:46:45 - Error: spawn ENOMEM at exports._errnoException (util.js:746:11) at ChildProcess.spawn (child_process.js:1162:11) at exports.spawn (child_process.js:995:9) at null. (/home/pi/.node-red/node_modules/node-red-node-ping/88-ping.js:30:41) at wrapper as _onTimeout at Timer.listOnTimeout (timers.js:119:15)

andysc avatar Jan 27 '16 20:01 andysc

how was this running ? Is this on Pi... what was --max-old-space-size set to ? (default is 128)

dceejay avatar Jan 27 '16 20:01 dceejay

yes, on Pi, with --max-old-space-size=256

andysc avatar Jan 27 '16 21:01 andysc

Slightly tricky one this... we could just try and catch the error - but then we would still not be pinging the host (but yes would not be crashing Node-RED) Or we could try to re-write the node so it only spawns once... and runs "forever" (until redeploy etc) - but for that we need to use the -i interval parameter - which does NOT exist in windows ping command... Or we can rewrite using something like - https://www.npmjs.com/package/net-ping

dceejay avatar Jan 31 '16 18:01 dceejay

I'm wondering why it would have got this error, though - when it crashed, I was able to log in and do stuff on the Pi, so it evidently wasn't out of system memory...

andysc avatar Feb 01 '16 14:02 andysc

Not sure if this is relevant but I am beginning to suspect that this ping node is crashing my pi 3.

It's been running Node-red fine for ages. About 2 weeks ago I added some new custom nodes and since then the Pi has been becoming unresponsive and requiring power cycling (no response to ssh, does not serve any pages from node red)

A few days ago I removed all the new nodes other than ping but pi was still dying.

Today I investigated a bit more. 20 minutes after the pi boots the node process jumps to the top of cpu usage with 100% (or over) usage. If I call node-red-stop the cpu usage drops right back down again (but ssh still doesn't work until a reboot). I have now uninstalled the ping node and will see if the pi dies again.

Roaders avatar May 13 '16 19:05 Roaders

Nope, not the ping node. Still dying after removing it.

Roaders avatar May 14 '16 07:05 Roaders

How are you staying Node-RED. Does indeed sound like it's running out of memory. But 20 mins is very quick. What is the flow doing ?

bigmonkeyboy avatar May 14 '16 07:05 bigmonkeyboy

The flow is pretty complex but it's just for controlling my lights. I have Hue nodes and wemo nodes that are kicked off with http request nodes. Most of the time it is doing nothing (unless I call one of the http nodes). I am beginning to suspect that ssh not working is due to too many failed login attempts from bots. I am not sure what would make node cpu rocket but I have turned off port forwarding for now. It will be a pain if I can't have the page accessible from outside the house.... Thanks for the reply.

Roaders avatar May 14 '16 10:05 Roaders

@dceejay didn't think about rewriting to use https://www.npmjs.com/package/net-ping ?

in docker after ~ 1 week work a see many process ping and error

node-red  | 7 Feb 04:03:17 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 04:08:38 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 04:13:10 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 04:43:28 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 04:56:23 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 04:58:43 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 05:13:46 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 05:35:37 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 05:40:55 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 05:45:29 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 06:08:26 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 06:35:52 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 06:42:45 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 06:45:47 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 06:55:49 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 07:00:25 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 08:08:24 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 08:55:29 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 09:21:30 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 09:22:59 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 09:26:10 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 09:30:44 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 09:31:30 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 09:50:23 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 09:55:43 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 10:05:30 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 10:08:30 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 10:11:30 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 10:14:30 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 10:21:20 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 10:23:36 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 10:25:06 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT
node-red  | 7 Feb 10:50:30 - [info] [ping:45sec] ping - Host '192.168.0.30' process timeout - sending SIGINT

and container Node-Red use more cpu / memory in flow use node ping with timer 30 sec

twocolors avatar Feb 07 '24 08:02 twocolors

No - but more than happy to look at a Pull Request.

dceejay avatar Feb 07 '24 09:02 dceejay

for history not good idea use net-ping for this node, in install host windows . not easy compiled / install net-ping ... (it worked for me on win10/server 2016/server 2019, but it didn’t work on win7)

twocolors avatar Feb 12 '24 07:02 twocolors

ah - right - so it uses a binary and not pure JS... then yeah not such a great solution :-(

dceejay avatar Feb 12 '24 14:02 dceejay