调试分配失败-在Heroku上运行的Meteor应用程序的JavaScript堆内存不足



我正在努力解决我的流星应用程序在heroku上的内存问题。它偶尔崩溃,我还不确定在哪里看。调试这个问题的好方法是什么?

19 Aug 2021 16:55:33.386116 <190>1 2021-08-19T14:55:32.928297+00:00 app web.1 - - <--- Last few GCs --->
19 Aug 2021 16:55:33.38694 <190>1 2021-08-19T14:55:32.928297+00:00 app web.1 - -
19 Aug 2021 16:55:33.386268 <190>1 2021-08-19T14:55:32.928299+00:00 app web.1 - - [4:0x2f7bf10] 22203032 ms: Mark-sweep 253.4 (259.1) -> 253.3 (259.1) MB, 29.1 / 0.0 ms (average mu = 0.167, current mu = 0.001) allocation failure scavenge might not succeed
19 Aug 2021 16:55:33.386260 <190>1 2021-08-19T14:55:32.928299+00:00 app web.1 - - [4:0x2f7bf10] 22203060 ms: Mark-sweep 253.3 (259.1) -> 253.3 (258.1) MB, 28.7 / 0.0 ms (average mu = 0.097, current mu = 0.001) last resort GC in old space requested
19 Aug 2021 16:55:33.386258 <190>1 2021-08-19T14:55:32.9283+00:00 app web.1 - - [4:0x2f7bf10] 22203094 ms: Mark-sweep 253.3 (258.1) -> 253.2 (258.1) MB, 33.6 / 0.0 ms (average mu = 0.049, current mu = 0.001) last resort GC in old space requested
19 Aug 2021 16:55:33.38692 <190>1 2021-08-19T14:55:32.9283+00:00 app web.1 - -
19 Aug 2021 16:55:33.38694 <190>1 2021-08-19T14:55:32.928327+00:00 app web.1 - -
19 Aug 2021 16:55:33.386117 <190>1 2021-08-19T14:55:32.928328+00:00 app web.1 - - <--- JS stacktrace --->
19 Aug 2021 16:55:33.38694 <190>1 2021-08-19T14:55:32.928328+00:00 app web.1 - -
19 Aug 2021 16:55:33.386155 <190>1 2021-08-19T14:55:32.928329+00:00 app web.1 - - ==== JS stack trace =========================================
19 Aug 2021 16:55:33.38693 <190>1 2021-08-19T14:55:32.92833+00:00 app web.1 - -
19 Aug 2021 16:55:33.386136 <190>1 2021-08-19T14:55:32.92833+00:00 app web.1 - - Security context: 0x3ce8858008d1 <JSObject>
19 Aug 2021 16:55:33.386264 <190>1 2021-08-19T14:55:32.928337+00:00 app web.1 - - 0: builtin exit frame: parse(this=0x3ce88581ee79 <Object map = 0x2bcbf8b43639>,0x314cea480119 <Very long string[340422]>,0x3ce88581ee79 <Object map = 0x2bcbf8b43639>)
19 Aug 2021 16:55:33.38694 <190>1 2021-08-19T14:55:32.928337+00:00 app web.1 - -
19 Aug 2021 16:55:33.386323 <190>1 2021-08-19T14:55:32.928339+00:00 app web.1 - - 1: parseDDP [0xf014a910661] [/app/.meteor/heroku_build/app/programs/server/packages/ddp-common.js:195] [bytecode=0x3cb18e7ed9b1 offset=20](this=0x22adba89c151 <Object map = 0x2cd80ceb2619>,0x314cea480119 <Very long string[...
19 Aug 2021 16:55:33.38694 <190>1 2021-08-19T14:55:32.928339+00:00 app web.1 - -
19 Aug 2021 16:55:33.386175 <190>1 2021-08-19T14:55:32.92836+00:00 app web.1 - - FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
19 Aug 2021 16:55:33.386151 <190>1 2021-08-19T14:55:32.93641+00:00 app web.1 - - 1: 0xa1a640 node::Abort() [.meteor/heroku_build/bin/node]
19 Aug 2021 16:55:33.386183 <190>1 2021-08-19T14:55:32.937003+00:00 app web.1 - - 2: 0xa1aa4c node::OnFatalError(char const*, char const*) [.meteor/heroku_build/bin/node]
19 Aug 2021 16:55:33.386209 <190>1 2021-08-19T14:55:32.937581+00:00 app web.1 - - 3: 0xb9a68e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [.meteor/heroku_build/bin/node]
19 Aug 2021 16:55:33.386223 <190>1 2021-08-19T14:55:32.938134+00:00 app web.1 - - 4: 0xb9aa09 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [.meteor/heroku_build/bin/node]
19 Aug 2021 16:55:33.386139 <190>1 2021-08-19T14:55:32.938675+00:00 app web.1 - - 5: 0xd57c85 [.meteor/heroku_build/bin/node]
19 Aug 2021 16:55:33.386286 <190>1 2021-08-19T14:55:32.93925+00:00 app web.1 - - 6: 0xd685d8 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [.meteor/heroku_build/bin/node]
19 Aug 2021 16:55:33.386216 <190>1 2021-08-19T14:55:32.939792+00:00 app web.1 - - 7: 0xd36a6d v8::internal::Factory::NewRawTwoByteString(int, v8::internal::AllocationType) [.meteor/heroku_build/bin/node]
19 Aug 2021 16:55:33.386268 <190>1 2021-08-19T14:55:32.940373+00:00 app web.1 - - 8: 0xe459b4 v8::internal::JsonParser<unsigned short>::MakeString(v8::internal::JsonString const&, v8::internal::Handle<v8::internal::String>) [.meteor/heroku_build/bin/node]
19 Aug 2021 16:55:33.386197 <190>1 2021-08-19T14:55:32.941006+00:00 app web.1 - - 9: 0xe47e9e v8::internal::JsonParser<unsigned short>::ParseJsonValue() [.meteor/heroku_build/bin/node]
19 Aug 2021 16:55:33.386192 <190>1 2021-08-19T14:55:32.941579+00:00 app web.1 - - 10: 0xe486af v8::internal::JsonParser<unsigned short>::ParseJson() [.meteor/heroku_build/bin/node]
19 Aug 2021 16:55:33.386215 <190>1 2021-08-19T14:55:32.942066+00:00 app web.1 - - 11: 0xc4bc05 v8::internal::Builtin_JsonParse(int, unsigned long*, v8::internal::Isolate*) [.meteor/heroku_build/bin/node]
19 Aug 2021 16:55:33.386140 <190>1 2021-08-19T14:55:32.942758+00:00 app web.1 - - 12: 0x140df99 [.meteor/heroku_build/bin/node]

修改您的包。json脚本写入如下:

如果您正在使用free dyno (512mb ram)

"start": "node --optimize_for_size --max_old_space_size=460 server.js"

如果您使用的是标准版本(1024mb ram)

"start": "node --optimize_for_size --max_old_space_size=920 server.js"

警告:找到你的主入口文件,它可能是index.js, server.js等等。

裁判:https://devcenter.heroku.com/articles/node-memory-use

最新更新