2012-01-08 51 views
4

部署時,我的node.js應用程序遇到與內存有關的錯誤(即致命錯誤:CALL_AND_RETRY_0分配失敗 - 進程內存不足)。我想在本地剖析我的節點,看看什麼是吃掉內存,但不知道從哪裏開始。什麼是確定node.js中內存泄漏的好方法?

+2

這個問題在這裏回答:http://stackoverflow.com/questions/4918557/調試-memory-leaks-with-node-js-server – 2012-01-08 17:42:48

+0

那裏的答案(使用來自節點檢查器的分析器)讓我們使用標有「非常實驗」的東西,而不是作者自己推薦的東西。 – Zugwalt 2012-01-10 20:35:19

回答

2

您可以使用node-inspectorv8-profiler來做到這一點。從NPM安裝:

$ npm install v8-profiler 

,然後用它把堆快照(從說明服用):

var profiler = require('v8-profiler'); 
var snapshot = profiler.takeSnapshot([name])  //takes a heap snapshot 
+0

v8-profiler目前爲我打破:https://github.com/dannycoates/v8-profiler/issues/9 – Zugwalt 2012-01-10 20:34:12

+0

但是,當它再次工作,這可能是最好的方式,謝謝! – Zugwalt 2012-01-17 15:42:41