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

Node-red-node-arduino causing memory leaks on NodeJS v12.13.1

Open Tankfuzz opened this issue 5 years ago • 2 comments

Which node are you reporting an issue on?

Node-red-node-arduino

What are the steps to reproduce?

Enter into Raspberry Pi's terminal

What happens?

As node-red boots up, the memory leak warnings will appear, followed by an automated restart of node-red every time.

`Welcome to Node-RED

2 Dec 10:19:16 - [info] Node-RED version: v1.0.3 2 Dec 10:19:16 - [info] Node.js version: v12.13.1 2 Dec 10:19:16 - [info] Linux 4.19.75-v7l+ arm LE 2 Dec 10:19:16 - [info] Loading palette nodes 2 Dec 10:19:18 - [info] Dashboard version 2.18.0 started at /ui 2 Dec 10:19:18 - [info] Settings file : /home/pi/.node-red/settings.js 2 Dec 10:19:18 - [info] Context store : 'default' [module=memory] 2 Dec 10:19:18 - [info] User directory : /home/pi/.node-red 2 Dec 10:19:18 - [warn] Projects disabled : editorTheme.projects.enabled=false 2 Dec 10:19:18 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json 2 Dec 10:19:18 - [info] Server now running at http://127.0.0.1:1880/ 2 Dec 10:19:18 - [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.

2 Dec 10:19:18 - [info] Starting flows 2 Dec 10:19:18 - [info] Started flows (node:2431) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 ready listeners added to [Firmata]. Use emitter.setMaxListeners() to increase limit (node:2431) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 ready listeners added to [Firmata]. Use emitter.setMaxListeners() to increase limit (node:2431) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 ready listeners added to [Firmata]. Use emitter.setMaxListeners() to increase limit <--- Last few GCs ---> [2431:0x1fbc620] 119748 ms: Scavenge 253.9 (257.2) -> 252.5 (261.4) MB, 12.3 / 0.0 ms (average mu = 0.295, current mu = 0.287) allocation failure [2431:0x1fbc620] 121826 ms: Mark-sweep 253.6 (261.4) -> 253.4 (255.9) MB, 1339.2 / 0.1 ms (+ 591.2 ms in 1272 steps since start of marking, biggest step 7.5 ms, walltime since start of marking 2078 ms) (average mu = 0.249, current mu = 0.194) finalize <--- JS stacktrace ---> FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory nodered.service: Main process exited, code=killed, status=6/ABRT nodered.service: Failed with result 'signal'. nodered.service: Service RestartSec=100ms expired, scheduling restart. nodered.service: Scheduled restart job, restart counter is at 10. Stopped Node-RED graphical event wiring tool. Started Node-RED graphical event wiring tool.`

What do you expect to happen?

I expect Node-red to boot up with no warnings and it doesn't crash.

Please tell us about your environment:

  • [ ] Node-RED version: v1.0.3
  • [ ] node.js version: v12.13.1
  • [ ] npm version: v6.12.1
  • [ ] Platform/OS: Linux 4.19.75-v7l+ arm LE / Rasbian OS
  • [ ] Browser: Chromium

Notes: There were no more errors after I downgraded NodeJS to v10.17.0. I made this post to just inform everyone that the Arduino module may not work with the latest version of NodeJS :)

Tankfuzz avatar Dec 04 '19 03:12 Tankfuzz

I updated the arduino node last night to handle the maxEmitters warning. It works fine on node12 for me... So please retry with that.

When you did upgrade to node v12 - did you also remember to go into your ~/.node-red directory and run npm rebuild to rebuild the serialport code that this node uses ?

Is it possible to share your flow so I can try to recreate the issue here ? Thanks

dceejay avatar Dec 04 '19 13:12 dceejay

@dceejay Hello, I checked that Node-red is working fine with Node v12. I had a few issues so I just reinstalled Raspbian and installed Node-Red using the script. I did not do the rebuild as I didn't know I had to.

[{"id":"840478f0.7dc058","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"65b16c71.faafc4","type":"ui_switch","z":"840478f0.7dc058","name":"","label":"Power","tooltip":"","group":"c1a8c0b2.c5274","order":1,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":530,"y":120,"wires":[["9e827bfc.c26208"]]},{"id":"3e59be25.f59f02","type":"ui_switch","z":"840478f0.7dc058","name":"","label":"Charging","tooltip":"","group":"c1a8c0b2.c5274","order":2,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":540,"y":180,"wires":[["b28d613f.52d9b"]]},{"id":"e4bb6f7e.c2663","type":"ui_switch","z":"840478f0.7dc058","name":"","label":"IN1","tooltip":"","group":"5a11130f.52311c","order":2,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"false","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"true","offvalueType":"bool","officon":"","offcolor":"","x":530,"y":380,"wires":[["66daa25.004675c"]]},{"id":"6079b6.052ac64c","type":"ui_switch","z":"840478f0.7dc058","name":"","label":"Manual Mode","tooltip":"","group":"5a11130f.52311c","order":1,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":560,"y":240,"wires":[["a13c8403.c48e58"]]},{"id":"566dd766.16f9a8","type":"ui_switch","z":"840478f0.7dc058","name":"","label":"IN2","tooltip":"","group":"5a11130f.52311c","order":3,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"false","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"true","offvalueType":"bool","officon":"","offcolor":"","x":530,"y":440,"wires":[["a6e39b16.324c58"]]},{"id":"952ef986.b1c988","type":"ui_button","z":"840478f0.7dc058","name":"","group":"c1a8c0b2.c5274","order":7,"width":0,"height":0,"passthru":false,"label":"Get Values","tooltip":"","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":550,"y":560,"wires":[["b38dbfeb.86392"]]},{"id":"d33f8621.2652f8","type":"ui_switch","z":"840478f0.7dc058","name":"","label":"IN3","tooltip":"","group":"5a11130f.52311c","order":4,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"false","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"true","offvalueType":"bool","officon":"","offcolor":"","x":530,"y":500,"wires":[["74fa3ba7.e191c4"]]},{"id":"b38dbfeb.86392","type":"ui_text","z":"840478f0.7dc058","group":"c1a8c0b2.c5274","order":8,"width":0,"height":0,"name":"","label":"Values test","format":"{{msg.payload}}","layout":"col-center","x":810,"y":560,"wires":[]},{"id":"9e827bfc.c26208","type":"arduino out","z":"840478f0.7dc058","name":"","pin":"28","state":"OUTPUT","arduino":"d386a890.aae718","x":790,"y":120,"wires":[]},{"id":"b28d613f.52d9b","type":"arduino out","z":"840478f0.7dc058","name":"","pin":"30","state":"OUTPUT","arduino":"d386a890.aae718","x":790,"y":180,"wires":[]},{"id":"a6e39b16.324c58","type":"arduino out","z":"840478f0.7dc058","name":"","pin":"24","state":"OUTPUT","arduino":"d386a890.aae718","x":790,"y":440,"wires":[]},{"id":"66daa25.004675c","type":"arduino out","z":"840478f0.7dc058","name":"","pin":"22","state":"OUTPUT","arduino":"d386a890.aae718","x":790,"y":380,"wires":[]},{"id":"a13c8403.c48e58","type":"arduino out","z":"840478f0.7dc058","name":"","pin":"32","state":"OUTPUT","arduino":"d386a890.aae718","x":790,"y":240,"wires":[]},{"id":"74fa3ba7.e191c4","type":"arduino out","z":"840478f0.7dc058","name":"","pin":"26","state":"OUTPUT","arduino":"d386a890.aae718","x":790,"y":500,"wires":[]},{"id":"340667c4.4d5ec8","type":"arduino in","z":"840478f0.7dc058","name":"","pin":"23","state":"INPUT","arduino":"d386a890.aae718","x":990,"y":120,"wires":[["ad8f9f9f.2e944"]]},{"id":"86ae018d.1e4d3","type":"arduino in","z":"840478f0.7dc058","name":"","pin":"25","state":"INPUT","arduino":"d386a890.aae718","x":990,"y":180,"wires":[["72cd5876.a7edb8"]]},{"id":"e44fbead.eab36","type":"arduino in","z":"840478f0.7dc058","name":"","pin":"27","state":"INPUT","arduino":"d386a890.aae718","x":990,"y":240,"wires":[["7eb1e21c.0ade2c"]]},{"id":"ad8f9f9f.2e944","type":"ui_text","z":"840478f0.7dc058","group":"75b4e5f8.d0804c","order":0,"width":0,"height":0,"name":"","label":"Close","format":"{{msg.payload}}","layout":"row-spread","x":1170,"y":120,"wires":[]},{"id":"72cd5876.a7edb8","type":"ui_text","z":"840478f0.7dc058","group":"75b4e5f8.d0804c","order":0,"width":0,"height":0,"name":"","label":"Close","format":"{{msg.payload}}","layout":"row-spread","x":1170,"y":180,"wires":[]},{"id":"7eb1e21c.0ade2c","type":"ui_text","z":"840478f0.7dc058","group":"75b4e5f8.d0804c","order":0,"width":0,"height":0,"name":"","label":"Close","format":"{{msg.payload}}","layout":"row-spread","x":1170,"y":240,"wires":[]},{"id":"56fbaf65.6d7ff","type":"ui_button","z":"840478f0.7dc058","name":"","group":"5a11130f.52311c","order":5,"width":0,"height":0,"passthru":false,"label":"Master relay reset","tooltip":"","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":330,"y":440,"wires":[["566dd766.16f9a8","e4bb6f7e.c2663","d33f8621.2652f8"]]},{"id":"6ea38a8e.6503f4","type":"arduino in","z":"840478f0.7dc058","name":"","pin":"0","state":"ANALOG","arduino":"d386a890.aae718","x":990,"y":740,"wires":[["a061d130.d37"]]},{"id":"a061d130.d37","type":"ui_gauge","z":"840478f0.7dc058","name":"","group":"7b1b75ba.d7bc2c","order":2,"width":0,"height":0,"gtype":"gage","title":"Analog Input test","label":"Ohms","format":"{{value}}","min":0,"max":"1024","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1250,"y":740,"wires":[]},{"id":"a53700d8.45414","type":"arduino out","z":"840478f0.7dc058","name":"","pin":"50","state":"OUTPUT","arduino":"d386a890.aae718","x":1220,"y":680,"wires":[]},{"id":"6b83fede.3ed77","type":"ui_switch","z":"840478f0.7dc058","name":"","label":"Digital Output test","tooltip":"","group":"7b1b75ba.d7bc2c","order":1,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":1030,"y":680,"wires":[["a53700d8.45414"]]},{"id":"163ae5b2.06bf0a","type":"inject","z":"840478f0.7dc058","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":370,"y":380,"wires":[["e4bb6f7e.c2663","566dd766.16f9a8","d33f8621.2652f8"]]},{"id":"e8d6052a.f56b28","type":"comment","z":"840478f0.7dc058","name":"Relay switches","info":"","x":560,"y":340,"wires":[]},{"id":"9ec66ff2.476b4","type":"comment","z":"840478f0.7dc058","name":"Relay switches indicators","info":"","x":1050,"y":80,"wires":[]},{"id":"c1a8c0b2.c5274","type":"ui_group","z":"","name":"Power/Charging","tab":"14704a36.ab4a26","disp":true,"width":"6","collapse":false},{"id":"5a11130f.52311c","type":"ui_group","z":"","name":"Manual Mode","tab":"14704a36.ab4a26","disp":true,"width":"6","collapse":false},{"id":"d386a890.aae718","type":"arduino-board","z":"","device":"/dev/ttyUSB0"},{"id":"75b4e5f8.d0804c","type":"ui_group","z":"","name":"Switch Status","tab":"4971384c.eaefa8","disp":true,"width":"6","collapse":false},{"id":"7b1b75ba.d7bc2c","type":"ui_group","z":"","name":"Arduin pin test","tab":"4971384c.eaefa8","disp":true,"width":"6","collapse":false},{"id":"14704a36.ab4a26","type":"ui_tab","z":"","name":"Control Panel","icon":"dashboard","disabled":false,"hidden":false},{"id":"4971384c.eaefa8","type":"ui_tab","z":"","name":"Indicator Panel","icon":"dashboard","disabled":false,"hidden":false}] Seems like I can't attach a file so I can only share my flow like this. Thanks!

Tankfuzz avatar Dec 06 '19 04:12 Tankfuzz