解释/比较Chrome开发工具中的node.js堆转储

时间:2014-05-04 16:46:37

标签: node.js garbage-collection google-chrome-devtools v8

我目前正在分析大型node.js应用程序中的内存泄漏/过多的内存使用问题。我尝试过的一件事是在使用heapdump节点模块和Chrome开发工具中的比较视图之前/之后查看V8堆。令人惊讶的是,即使在应用程序中没有做太多工作,连续堆转储之间似乎也会发生巨大变化,如此屏幕截图所示:

heap snapshot comparison view

(string)部分中最大的条目显然是应用程序node.js模块的完整源代码。我正在读取这个输出,在两个堆转储调用之间,所有字符串形式的JS代码(可能存储在节点的模块缓存/需要机制中的某个地方?)被垃圾收集并立即再次加载。这种解释是否正确?

我认为根本问题是:我在这里做些蠢事(即错误地使用这些工具),或应用程序真的表现得像看起来那么糟糕?

如果有帮助,这是堆转储期间来自--trace-gc --trace-gc-verbose的相应输出:

[3365]   202482 ms: Mark-sweep 142.5 (180.2) -> 113.9 (175.2) MB, 216 ms (+ 108 ms in 529 steps since start of marking, biggest step 1.946777 ms) [HeapSnapshotGenerator::GenerateSnapshot] [GC in old space requested].
[3365] Memory allocator,   used: 179432 KB, available: 1319704 KB
[3365] New space,          used:      4 KB, available:  16379 KB, committed:  32768 KB
[3365] Old pointers,       used:  48953 KB, available:  19074 KB, committed:  68031 KB
[3365] Old data space,     used:  44059 KB, available:   3745 KB, committed:  48564 KB
[3365] Code space,         used:  13451 KB, available:    292 KB, committed:  13944 KB
[3365] Map space,          used:   6577 KB, available:   1612 KB, committed:   8190 KB
[3365] Cell space,         used:    301 KB, available:    834 KB, committed:   1135 KB
[3365] Large object space, used:   3249 KB, available: 1318663 KB, committed:   3281 KB
[3365] All spaces,         used: 116597 KB, available:  41938 KB, committed: 175914 KB
[3365] Total time spent in GC  : 586 ms
[3365]   202637 ms: Mark-sweep 113.9 (175.2) -> 113.7 (167.2) MB, 152 ms [HeapSnapshotGenerator::GenerateSnapshot] [GC in old space requested].
[3365] Memory allocator,   used: 171240 KB, available: 1327896 KB
[3365] New space,          used:      0 KB, available:  16384 KB, committed:  32768 KB
[3365] Old pointers,       used:  48841 KB, available:  13142 KB, committed:  61984 KB
[3365] Old data space,     used:  44028 KB, available:   2226 KB, committed:  46548 KB
[3365] Code space,         used:  13388 KB, available:    555 KB, committed:  13944 KB
[3365] Map space,          used:   6577 KB, available:   1612 KB, committed:   8190 KB
[3365] Cell space,         used:    301 KB, available:    834 KB, committed:   1135 KB
[3365] Large object space, used:   3249 KB, available: 1326855 KB, committed:   3281 KB
[3365] All spaces,         used: 116386 KB, available:  34755 KB, committed: 167852 KB
[3365] Total time spent in GC  : 738 ms

0 个答案:

没有答案