简体   繁体   English

Discord Bot (Node.js) 的 Heroku 内存错误

[英]Heroku Memory Error for Discord Bot (Node.js)

For some reason, I keep getting this error once in a while and I don't know how to fix it.出于某种原因,我偶尔会收到此错误,但我不知道如何解决。 The memory keeps saying that it is over exceeded and it causes my bot having to restart where I don't want it to.内存一直说它已经超过了,这导致我的机器人不得不在我不希望的地方重新启动。 This causes issues for my CURRENT code in the bot and I don't know how to fix those issues.这会导致我在机器人中的当前代码出现问题,我不知道如何解决这些问题。 Any ideas?有任何想法吗?

Thanks!谢谢!

 2020-10-03T17:13:14.381800+00:00 app[Worker.1]: 2020-10-03T17:13:14.381830+00:00 app[Worker.1]: <--- Last few GCs ---> 2020-10-03T17:13:14.381831+00:00 app[Worker.1]: 2020-10-03T17:13:14.381835+00:00 app[Worker.1]: [4:0x3d6e300] 10517035 ms: Mark-sweep 251.8 (257.5) -> 251.8 (257.5) MB, 654.6 / 0.0 ms (average mu = 0.193, current mu = 0.058) allocation failure GC in old space requested 2020-10-03T17:13:14.381835+00:00 app[Worker.1]: [4:0x3d6e300] 10517658 ms: Mark-sweep 251.8 (257.5) -> 251.7 (257.5) MB, 569.5 / 0.0 ms (average mu = 0.145, current mu = 0.084) allocation failure GC in old space requested 2020-10-03T17:13:14.381836+00:00 app[Worker.1]: 2020-10-03T17:13:14.381836+00:00 app[Worker.1]: 2020-10-03T17:13:14.381837+00:00 app[Worker.1]: <--- JS stacktrace ---> 2020-10-03T17:13:14.381837+00:00 app[Worker.1]: 2020-10-03T17:13:14.381838+00:00 app[Worker.1]: ==== JS stack trace ========================================= 2020-10-03T17:13:14.381838+00:00 app[Worker.1]: 2020-10-03T17:13:14.381839+00:00 app[Worker.1]: 0: ExitFrame [pc: 0x13cf099] 2020-10-03T17:13:14.381840+00:00 app[Worker.1]: 1: StubFrame [pc: 0x142b232] 2020-10-03T17:13:14.381840+00:00 app[Worker.1]: Security context: 0x3f8bca2008d1 <JSObject> 2020-10-03T17:13:14.381841+00:00 app[Worker.1]: 2: nextTick [0xb3f0cf95c01] [internal/process/task_queues.js:129] [bytecode=0x60fb2779c41 offset=319](this=0x2fa425bbfb09 <process map = 0x3912d8e02559>,0x0414e95ed279 <JSFunction onSocketNT (sfi = 0x10e0661aebe1)>) 2020-10-03T17:13:14.381842+00:00 app[Worker.1]: 3: arguments adaptor frame: 3->1 2020-10-03T17:13:14.381842+00:00 app[Worker.1]: 4: onSocket [0x10e0661b9ca9] [_http_client.js:732] [bytecode=0x60fb2774... 2020-10-03T17:13:14.381843+00:00 app[Worker.1]: 2020-10-03T17:13:14.381843+00:00 app[Worker.1]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 2020-10-03T17:13:14.423372+00:00 app[Worker.1]: 1: 0xa093f0 node::Abort() [node] 2020-10-03T17:13:14.426419+00:00 app[Worker.1]: 2: 0xa097fc node::OnFatalError(char const*, char const*) [node] 2020-10-03T17:13:14.427061+00:00 app[Worker.1]: 3: 0xb8431e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node] 2020-10-03T17:13:14.427693+00:00 app[Worker.1]: 4: 0xb84699 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node] 2020-10-03T17:13:14.428406+00:00 app[Worker.1]: 5: 0xd31055 [node] 2020-10-03T17:13:14.429136+00:00 app[Worker.1]: 6: 0xd316e6 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node] 2020-10-03T17:13:14.437880+00:00 app[Worker.1]: 7: 0xd3df65 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node] 2020-10-03T17:13:14.441802+00:00 app[Worker.1]: 8: 0xd3ee15 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node] 2020-10-03T17:13:14.445799+00:00 app[Worker.1]: 9: 0xd418cc v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node] 2020-10-03T17:13:14.447204+00:00 app[Worker.1]: 10: 0xd0df81 v8::internal::Factory::NewTransitionArray(int, int) [node] 2020-10-03T17:13:14.447945+00:00 app[Worker.1]: 11: 0xf56bb7 v8::internal::TransitionsAccessor::Insert(v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::Map>, v8::internal::SimpleTransitionFlag) [node] 2020-10-03T17:13:14.448645+00:00 app[Worker.1]: 12: 0xf036ca v8::internal::Map::ConnectTransition(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::Name>, v8::internal::SimpleTransitionFlag) [node] 2020-10-03T17:13:14.457851+00:00 app[Worker.1]: 13: 0xf05d4e v8::internal::Map::CopyReplaceDescriptors(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::DescriptorArray>, v8::internal::Handle<v8::internal::LayoutDescriptor>, v8::internal::TransitionFlag, v8::internal::MaybeHandle<v8::internal::Name>, char const*, v8::internal::SimpleTransitionFlag) [node] 2020-10-03T17:13:14.458563+00:00 app[Worker.1]: 14: 0xf0635a v8::internal::Map::CopyAddDescriptor(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Map>, v8::internal::Descriptor*, v8::internal::TransitionFlag) [node] 2020-10-03T17:13:14.459277+00:00 app[Worker.1]: 15: 0xf06599 v8::internal::Map::CopyWithField(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::FieldType>, v8::internal::PropertyAttributes, v8::internal::PropertyConstness, v8::internal::Representation, v8::internal::TransitionFlag) [node] 2020-10-03T17:13:14.459963+00:00 app[Worker.1]: 16: 0xf07d82 v8::internal::Map::TransitionToDataProperty(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::internal::PropertyConstness, v8::internal::StoreOrigin) [node] 2020-10-03T17:13:14.460645+00:00 app[Worker.1]: 17: 0xef841f v8::internal::LookupIterator::PrepareTransitionToDataProperty(v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::internal::StoreOrigin) [node] 2020-10-03T17:13:14.461317+00:00 app[Worker.1]: 18: 0xf2bb66 v8::internal::Object::AddDataProperty(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::Maybe<v8::internal::ShouldThrow>, v8::internal::StoreOrigin) [node] 2020-10-03T17:13:14.470104+00:00 app[Worker.1]: 19: 0xed7010 v8::internal::JSObject::DefineOwnPropertyIgnoreAttributes(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::Maybe<v8::internal::ShouldThrow>, v8::internal::JSObject::AccessorInfoHandling) [node] 2020-10-03T17:13:14.470851+00:00 app[Worker.1]: 20: 0x1062ee8 v8::internal::Runtime_DefineDataPropertyInLiteral(int, unsigned long*, v8::internal::Isolate*) [node] 2020-10-03T17:13:14.471641+00:00 app[Worker.1]: 21: 0x13cf099 [node] 2020-10-03T17:13:14.614446+00:00 heroku[Worker.1]: Process exited with status 134

With the Heroku free tier you can use up to 512MB.使用 Heroku 免费套餐,您最多可以使用 512MB。

The first thing to do is to check locally how much memory your application is using, then profiling/improving.首先要做的是在本地检查您的应用程序使用了多少内存,然后进行分析/改进。 As you use NodeJS there are several resources available, one interesting blog to start is Understanding memory leaks in Node.js apps and also the Heroku NodeJS Memory use当你使用 NodeJS 时,有几个可用的资源,一个有趣的博客开始是了解 Node.js 应用程序中的内存泄漏以及Heroku NodeJS 内存使用

One factor to consider is that Heroku memory usage might be different from your local instance, I have had this problem and, after some tuning, I couldnt reduce the memory footprint anymore (in my case I moved my app to a different cloud provider and solved the problem).要考虑的一个因素是 Heroku 内存使用可能与您的本地实例不同,我遇到了这个问题,经过一些调整后,我无法再减少内存占用(在我的情况下,我将我的应用程序移到了不同​​的云提供商并解决了问题)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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