【发布时间】:2017-01-06 11:09:59
【问题描述】:
我正在开发一个 Node JS 应用程序并面临严重的内存压力问题。以下是应用程序启动后 60 分钟内的内存使用趋势(在恒定负载下):
内存使用率急剧上升到 95%,但之后保持相当稳定。
我之前和之后都进行了内存转储,但我捕获转储的方式似乎存在一些问题,因为两个转储文件之间的差异只有几 MB。
这是堆转储在 chrome 分析中的样子:
但我对此很陌生,不知道我应该寻找什么。
谁能提供任何关于如何找出这里的内存问题、如何检测内存泄漏或如何理解这里提到的 heapdump 文件的指示?
节点版本:0.12.14
- find node_modules -type f -name "*.node" - 的输出如下:
node_modules/simpleflake/node_modules/bignum/build/Release/bignum.node
node_modules/simpleflake/node_modules/bignum/build/Release/obj.target/bignum.node
node_modules/heapdump/build/Release/addon.node
node_modules/heapdump/build/Release/obj.target/addon.node
node_modules/couchbase/build/Release/couchbase_impl.node
- npm list --depth=0 - 的输出如下:
aws-sdk@2.5.3
body-parser@1.11.0
check-types@6.0.0
couchbase@2.2.2
elasticsearch@10.1.3
expect@1.20.2
express@4.14.0
jshint@2.9.3
minimist@1.1.3
mocha@2.5.3
moment@2.9.0
morgan@1.5.3
newrelic@1.30.0
request@2.53.0
simpleflake@1.0.0
underscore@1.7.0
why-is-node-running@1.2.2 (https://github.com/mindtickle/why-is-node-running.git#96f3c8da54b110e8a9a1423361d2da7c125784f6)
winston@1.0.2
winston-aws-cloudwatch@0.4.2
另外,是否有可能查看我正在使用的任何包是否会导致内存泄漏?
提前致谢。
【问题讨论】:
-
您使用的是什么版本的节点?
node --version你在运行什么原生模块?find node_modules -type f -name "*.node" -
你是如何生成物理内存图的?
-
嗨,马特,感谢您的关注,我已经编辑了这个问题,提供了有关节点版本和所用软件包的更多信息。并且,该图取自 newrelic(newrelic 代理在服务器上运行,提供实时服务器数据)
-
好的。我不知道 newrelic 是如何收集到的。。在系统处于完整内存状态时尝试
free或cat /proc/meminfo。 -
@Matt - 毫无疑问,这些内存使用数字是否正确。系统内存不足,应用程序崩溃。此外,newrelic 代理已经在这台机器上运行了很长时间。
标签: node.js memory memory-leaks node-heapdump