简体   繁体   中英

Reached heap limit Allocation failed - JavaScript heap out of memory on EB / AL2

I have a node.js app running on AL2 Elastic Beanstalk - t2.micro. When I am deleting several documents from my ios app, the server will routinely stop responding for almost 10 minutes. Here is the log:

Nov 22 06:24:54 ip-172-31-46-248 web: <--- Last few GCs --->
Nov 22 06:24:54 ip-172-31-46-248 web: [32206:0x5803f50]  5317454 ms: Mark-sweep (reduce) 489.0 (500.6) -> 488.4 (500.8) MB, 1003.0 / 0.0 ms  (average mu = 0.209, current mu = 0.153) allocation failure scavenge might not succeed
Nov 22 06:24:54 ip-172-31-46-248 web: [32206:0x5803f50]  5318798 ms: Mark-sweep (reduce) 489.6 (500.8) -> 488.9 (501.1) MB, 1162.6 / 0.0 ms  (average mu = 0.170, current mu = 0.135) allocation failure scavenge might not succeed
Nov 22 06:24:54 ip-172-31-46-248 web: <--- JS stacktrace --->
Nov 22 06:24:54 ip-172-31-46-248 web: FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
Nov 22 06:24:54 ip-172-31-46-248 web: 1: 0xb06730 node::Abort() [node]
Nov 22 06:24:54 ip-172-31-46-248 web: 2: 0xa1b6d0  [node]
Nov 22 06:24:54 ip-172-31-46-248 web: 3: 0xce1dd0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
Nov 22 06:24:54 ip-172-31-46-248 web: 4: 0xce2177 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
Nov 22 06:24:54 ip-172-31-46-248 web: 5: 0xe997e5  [node]
Nov 22 06:24:54 ip-172-31-46-248 web: 6: 0xea94ad v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
Nov 22 06:24:54 ip-172-31-46-248 web: 7: 0xeac1ae v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
Nov 22 06:24:54 ip-172-31-46-248 web: 8: 0xe6d6ea v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
Nov 22 06:24:54 ip-172-31-46-248 web: 9: 0x11e6456 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
Nov 22 06:24:54 ip-172-31-46-248 web: 10: 0x15da0d9  [node]
Nov 22 06:24:55 ip-172-31-46-248 web: > start
Nov 22 06:24:55 ip-172-31-46-248 web: > node app.js

How do I resolve this?

You may need a bigger EC2 instance to run your code. As you can read in the error messages the problem is that your server ran out of memory. Going for a small or medium sized instance would therefore probably solve your memory problem. Alternatively, your code could also be a problem if it's not working properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM