所以这是我运行节点程序大约10分钟后得到的错误。
<--- Last few GCs --->
186465 ms: Mark-sweep 1788.2 (4117.3) -> 1787.6 (4128.3) MB, 275.4 / 0.0 ms [allocation failure] [GC in old space requested].
186782 ms: Mark-sweep 1787.6 (4128.3) -> 1787.3 (4130.3) MB, 316.6 / 0.0 ms [allocation failure] [GC in old space requested].
187141 ms: Mark-sweep 1787.3 (4130.3) -> 1811.6 (4099.3) MB, 358.8 / 0.0 ms [last resort gc].
187450 ms: Mark-sweep 1811.6 (4099.3) -> 1836.3 (4099.3) MB, 309.5 / 0.0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0xc0338acfb51 <JS Object>
1: parse [native json.js:~61] [pc=0xb9af5c3b3e1] (this=0xc0338ac9111 <a JSON with map 0x26b709e0a0e1>,C=0x16719f063189 <Very long string[13958430]>,w=0xc0338a04381 <undefined>)
2: arguments adaptor frame: 1->2
3: onreadystatechange [/Users/harryfeng/Documents/javascriptKitchen-Sink/node_modules/parse/lib/node/RESTController.js:110] [pc=0xb9af5c64295] (this=0x26c045d78981 <JS Object>)...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [/usr/local/bin/node]
2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
4: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/usr/local/bin/node]
5: v8::internal::String::SlowFlatten(v8::internal::Handle<v8::internal::ConsString>, v8::internal::PretenureFlag) [/usr/local/bin/node]
6: v8::internal::Runtime_ParseJson(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
7: 0xb9af52092a7
Abort trap: 6
我知道这是记忆问题,但这一行:
Security context: 0xc0338acfb51 <JS Object>
是否可以找到导致问题的对象?它有一个软件,可以帮助我在我的代码中找到这个对象,以便我知道如何修复它?
感谢。
答案 0 :(得分:0)
是。我使用heapdump将堆转储写入文件以供以后分析 - 它可以加载到Chrome开发工具中。
如果您知道应用程序崩溃时堆的大小,您可以使用process.memoryUsage().heapUsed
来监控当前大小,以便您可以在达到崩溃阈值之前创建堆转储一段时间。