Cos
Cos

Reputation: 1709

Debugging Allocation failed - JavaScript heap out of memory for Meteor App running on Heroku

I'm struggling with memory issues on heroku for my meteor app. It occasionally crashes and I'm not yet sure where to look. What is a good way to debug this issue?

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]

Upvotes: 1

Views: 614

Answers (1)

Hasan Ahamed
Hasan Ahamed

Reputation: 408

Modify your package.json start script to something like this:

if you are using free dyno (512mb ram)

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

if you are using standard version (1024mb ram)

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

warning: find your main entry file, it could be index.js, server.js whatever.

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

Upvotes: 1

Related Questions