将Nativescript应用程序与Webpack捆绑在一起时出现Javascript堆错误

时间:2019-03-26 12:17:22

标签: webpack nativescript nativescript-angular

将nativescript应用程序与webpack捆绑在一起时,出现Javascript堆错误。

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

这是使用

运行时遇到的错误

tns run android --bundle --env.aot --env.uglify

nativescript version 5.2.2
@angular/core: "~7.2.0
nativescript-dev-webpack": "^0.20.3
@angular/compiler-cli": "~7.2.0

详细日志

<---后几个GC --->

  

[31199:0x24e6180] 38234毫秒:标记扫描1367.2(1453.5)-> 1363.6   (1458.5)MB,912.0 / 0.0 ms(平均亩= 0.116,当前亩= 0.044)   分配失败清除可能不会成功[31199:0x24e6180]
  39132 ms:标记扫描1372.4(1458.5)-> 1368.5(1458.5)MB,844.5 /   请求的旧空间中有0.0 ms(平均亩= 0.087,当前亩= 0.060)分配失败GC

<--- JS堆栈跟踪--->

==== JS堆栈跟踪======================================== =

0: ExitFrame [pc: 0x2d645c5dbe1d]
Security context: 0x10886211e6e1 <JSObject>
1: bindWorker(aka bindWorker) [0x39b993a31201] 
[/home/user/jishnu/projects/oes-dt- 
mobile/node_modules/typescript/lib/typescript.js:~28311] [pc=0x2d645d75c74d] 
(this=0x005cd5b026f1 <undefined>,node=0x06f6ec3100a1 <NodeObject map = 
0xe7113ce3aa1>)
2: bind(aka bind) [0x39b993a31101] [/home/user/jishnu/projects/oes-dt- 
mobile/node_modules/typescript/lib/ty...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x8daaa0 node::Abort() [node]
 2: 0x8daaec  [node]
 3: 0xad73ce v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xad7604 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xec4c32  [node]
 6: 0xec4d38 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [node]
 7: 0xed0e12 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]
 8: 0xed1744 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 9: 0xed43b1 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [node]
10: 0xe9c695  [node]
11: 0xea1354 v8::internal::Factory::NewByteArray(int, v8::internal::PretenureFlag) [node]
12: 0xe2a88a v8::internal::TranslationBuffer::CreateByteArray(v8::internal::Factory*) [node]
13: 0xc41edf v8::internal::compiler::CodeGenerator::GenerateDeoptimizationData() [node]
14: 0xc42672 v8::internal::compiler::CodeGenerator::FinalizeCode() [node]
15: 0xd5167b v8::internal::compiler::PipelineImpl::FinalizeCode() [node]
16: 0xd51a8d v8::internal::compiler::PipelineCompilationJob::FinalizeJobImpl(v8::internal::Isolate*) [node]
17: 0xc1562d v8::internal::Compiler::FinalizeCompilationJob(v8::internal::OptimizedCompilationJob*, v8::internal::Isolate*) [node]
18: 0xc0bbbb v8::internal::OptimizingCompileDispatcher::InstallOptimizedFunctions() [node]
19: 0xe720bb v8::internal::StackGuard::HandleInterrupts() [node]
20: 0x113ced5 v8::internal::Runtime_StackGuard(int, v8::internal::Object**, v8::internal::Isolate*) [node]
21: 0x2d645c5dbe1d

不带--bundle的命令tns run不存在错误。在为某些应用程序优化添加了一些工作程序之后,出现了错误。跟NativeScript Worker Loader and NativeScriptWorkerPlugin一起使用webpack捆绑添加工作人员。

1 个答案:

答案 0 :(得分:0)

在终端窗口中运行以下命令:

export NODE_OPTIONS=--max-old-space-size=4096

然后运行tns run ...命令,它应该可以解决问题。

如果将export ...添加到〜/ .bashrc(或类似名称)中,则不必在每次启动新终端时手动运行它。