节点红色内存不足问题

时间:2019-03-04 21:55:02

标签: node.js npm raspberry-pi node-red

我使用此文档(Node-red doc for RPI)进行节点红色安装。安装工作正常。但是在启动node-red-startnode-red-pi之后,我看到下一个有错误的日志。我不是nodejs的专家。日志中是npm和nodejs版本。

Mar 22:48:23 - [info] 

Welcome to Node-RED
===================

4 Mar 22:48:23 - [info] Node-RED version: v0.19.6
4 Mar 22:48:23 - [info] Node.js  version: v10.15.2
4 Mar 22:48:23 - [info] Linux 4.9.35-v7+ arm LE
4 Mar 22:48:25 - [info] Loading palette nodes
4 Mar 22:48:30 - [info] Worldmap version 1.5.29
4 Mar 22:48:31 - [info] Dashboard version 2.14.0 started at /ui
4 Mar 22:48:35 - [warn] ------------------------------------------------------
4 Mar 22:48:35 - [warn] [node-red-contrib-generic-ble/generic-ble] Error: Cannot find module 'bluetooth-hci-socket'
4 Mar 22:48:35 - [warn] ------------------------------------------------------
4 Mar 22:48:35 - [info] Settings file  : /home/pi/.node-red/settings.js
4 Mar 22:48:35 - [info] Context store  : 'default' [module=memory]
4 Mar 22:48:35 - [info] User directory : /home/pi/.node-red
4 Mar 22:48:35 - [warn] Projects disabled : editorTheme.projects.enabled=false
4 Mar 22:48:35 - [info] Flows file     : /home/pi/.node-red/flows_server.json
4 Mar 22:48:35 - [info] Server now running at https://127.0.0.1:1880/
4 Mar 22:48:35 - [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.
---------------------------------------------------------------------

4 Mar 22:48:35 - [info] Starting flows
4 Mar 22:48:37 - [info] [worldmap:1ac45205.ff98ee] started at /worldmap
4 Mar 22:48:37 - [info] [worldmap:ac8fa4a4.314918] started at /worldmap
4 Mar 22:48:38 - [info] [worldmap:20c6db58.a44e34] started at /worldmap
4 Mar 22:48:38 - [info] [worldmap:bf26442c.e7f3b8] started at /worldmap
4 Mar 22:48:38 - [info] [worldmap:ee74d5bc.e8f268] started at /worldmap
4 Mar 22:48:38 - [info] Started flows
4 Mar 22:48:38 - [info] [mqtt-broker:mqtt] Connected to broker: mqtt://localhost:1883

<--- Last few GCs --->

[24581:0x34f1a28]   138171 ms: Mark-sweep 702.7 (729.7) -> 702.7 (733.2) MB, 9657.7 / 0.1 ms  (average mu = 0.092, current mu = 0.004) allocation failure scavenge might not succeed
[24581:0x34f1a28]   148339 ms: Mark-sweep 706.3 (733.2) -> 706.3 (733.2) MB, 9979.6 / 0.1 ms  (average mu = 0.055, current mu = 0.019) allocation failure scavenge might not succeed


<--- JS stacktrace --->
Cannot get stack trace in GC.
FATAL ERROR: MarkCompactCollector: semi-space copy, fallback in old gen Allocation failed - JavaScript heap out of memory

现在我有更多可用信息,堆栈跟踪...

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x37deae9c]
    1: StubFrame [pc: 0x37dec080]
Security context: 0x4b492701 <JSObject>
    2: encode(aka encode) [0x4fdd867d] [/home/pi/.node-red/node_modules/qs/lib/utils.js:~118] [pc=0x20067594](this=0x36c8438d <undefined>,str=0x43a423d1 <Very long string[17508]>)
    3: arguments adaptor frame: 2->1
    4: stringify(aka stringify) [0x4fdd737d] [/home/pi/.node-red/node_modules/qs/lib/stringify.js:61] [bytecode=0x289...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

这意味着在我的节点中有错误的节点?如果是,如何找到哪个节点出错?

2 个答案:

答案 0 :(得分:2)

该错误的重要部分是:

 fallback in old gen Allocation failed - JavaScript heap out of memory

这意味着运行Node-RED的NodeJS虚拟机内存不足。

如果没有正确了解流的运行状况,就无法说出发生这种情况的原因,但是可以合理地猜测是,您要么试图处理(从某个地方来的)传入消息慢于它们到达的速度,要么是因为您将事物存储在上下文中,并且从不删除它们,所以它们会随着时间的推移而积累。

编辑:

OOM的堆栈跟踪不一定有帮助,这只是在没有更多空间的情况下试图分配的内容。这并不意味着是原因。

如前所述,调试此错误的唯一方法是详细了解流的工作方式(而Stack Overflow可能不是解决此问题的最佳方法。您可以在Node-RED论坛或松懈的地方,您可能会找到可以与您一起工作的人)

答案 1 :(得分:0)

问题是错误的电报节点配置。这已将qs/lib/utils.js:~118中的self称为字符串更大,直到堆空间...

Thx