【问题标题】:Angular 7 FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memoryAngular 7 致命错误:接近堆限制的无效标记压缩分配失败 - JavaScript 堆内存不足
【发布时间】:2019-07-15 04:37:15
【问题描述】:

我的项目很大。在上一个版本中,我添加了大量新功能。构建过程给了我这个错误日志。

更改 --max-old-space-size=4096 对我不起作用。

{ Error: Command failed: ng build --prod --configuration=config --output-path=test --base-href=/test/ FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 0x8dbaa0 node::Abort() [ng build --prod --configuration=config --output-path=test --base-href=/test/] 2: 0x8dbaec [ng build --prod --configuration=config --output-path=test --base-href=/test/] 3: 0xad83de v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [ng build --prod --configuration=config --output-path=test --base-href=/test/] 4: 0xad8614 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [ng build --prod --configuration=config --output-path=test --base-href=/test/] 5: 0xec5c42 [ng build --prod --configuration=config --output-path=test --base-href=/test/] 6: 0xec5d48 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [ng build --prod --configuration=config --output-path=test --base-href=/test/] 7: 0xed1e22 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [ng build --prod --configuration=config --output-path=test --base-href=/test/] 8: 0xed2754 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [ng build --prod --configuration=config --output-path=test --base-href=/test/] 9: 0xed53c1 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [ng build --prod --configuration=config --output-path=test --base-href=/test/] 10: 0xe9d636 [ng build --prod --configuration=config --output-path=test --base-href=/test/] 11: 0xeafee7 v8::internal::Factory::NewLoadHandler(int) [ng build --prod --configuration=config --output-path=test --base-href=/test/] 12: 0xf2f4db v8::internal::LoadHandler::LoadFromPrototype(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::Handle<v8::internal::Smi>, v8::internal::MaybeHandle<v8::internal::Object>, v8::internal::MaybeHandle<v8::internal::Object>) [ng build --prod --configuration=config --output-path=test --base-href=/test/] 13: 0xf36d1f v8::internal::LoadIC::ComputeHandler(v8::internal::LookupIterator*) [ng build --prod --configuration=config --output-path=test --base-href=/test/] 14: 0xf3d94c v8::internal::LoadIC::UpdateCaches(v8::internal::LookupIterator*) [ng build --prod --configuration=config --output-path=test --base-href=/test/] 15: 0xf3dffc v8::internal::LoadIC::Load(v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Name>) [ng build --prod --configuration=config --output-path=test --base-href=/test/] 16: 0xf42935 v8::internal::Runtime_LoadIC_Miss(int, v8::internal::Object**, v8::internal::Isolate*) [ng build --prod --configuration=config --output-path=test --base-href=/test/] 17: 0x235e3925be1d

【问题讨论】:

  • 可以分享一下构建命令吗?
  • 您需要检查池,将池从 'ubantu-latest' 替换为 'windows-latest' 这解决了我的问题。

标签: angular angular-cli angular7 ng-build


【解决方案1】:

你能用下面的 prod 命令试试 --max-old-space-size=8192

node --max-old-space-size=8192 ./node_modules/@angular/cli/bin/ng build --aot=true --optimization=true --source-map=false

【讨论】:

    【解决方案2】:

    package.json 中的 npm 命令添加到如下脚本中:

    “脚本”:{
    “ng”:“ng”,
    "start": "ng serve",
    "go": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng serve",
    .
    .

    然后在命令行或终端中使用 npm run go

    【讨论】:

      【解决方案3】:

      我认为主要问题是您需要使用下划线而不是破折号。

      --max_old_space_size=4096
      

      4096 可能不够,您可以按照建议尝试将其增加到 8192。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-09-11
        • 2020-08-05
        • 2019-07-06
        • 2020-04-17
        • 2020-09-10
        • 2023-03-18
        • 2019-05-05
        • 2020-08-22
        相关资源
        最近更新 更多