【发布时间】:2014-09-01 11:40:50
【问题描述】:
我一直在追查节点程序中一个非常糟糕的内存泄漏。
我正在使用 memwatch 模块 HeapDiff() 来尝试识别违规对象。
HeapDiff 的报告显示 details 数组中有两个可疑元素(“Array”和“String”,每个元素都有很大的增长。
我正式迷路了,不知道如何缩小可能的罪魁祸首。 有几十个 google-able howtos,但对我来说没有任何意义。有问题的程序使用了很多 3rd 方模块,包括载体、出队和 mqtt。 318行代码所以没贴出来。
我会很感激任何关于我下一步应该做什么的指示......
这是 memwatch HeapDiff 转储的摘录:
{
"before": {
"nodes": 25312,
"time": "2014-09-01T10:59:24.000Z",
"size_bytes": 3596320,
"size": "3.43 mb"
},
"after": {
"nodes": 125705,
"time": "2014-09-01T11:14:24.000Z",
"size_bytes": 20255728,
"size": "19.32 mb"
},
"change": {
"size_bytes": 16659408,
"size": "15.89 mb",
"freed_nodes": 674,
"allocated_nodes": 101067,
"details": [
{
"what": "Array",
"size_bytes": 348440,
"size": "340.27 kb",
"+": 1592,
"-": 295
},
{
"what": "String",
"size_bytes": 12580056,
"size": "12 mb",
"+": 50329,
"-": 20
}
]
【问题讨论】:
-
12mb 的字符串看起来很奇怪。我会寻找任何将字符添加到关闭的字符串的函数。如果没有代码,我将无法再提供帮助。
标签: node.js memory-leaks node-memwatch