• home > tools > Bundler > vite >

    vitepress 打包内存溢出: JavaScript heap out of memory

    Author:zhoulujun Date:

    解决问题:1、vitepress build FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memo……2、 (!) Found dead link

    vitepress 打包项目,报错:

    building client + server bundles...

    <--- Last few GCs --->


    [16421:0x7fc745100000]  5970612 ms: Scavenge (reduce) 4051.4 (4142.6) -> 4050.7 (4142.8) MB, 7.4 / 0.0 ms  (average mu = 0.075, current mu = 0.001) allocation failure 

    [16421:0x7fc745100000]  5981918 ms: Mark-sweep (reduce) 4051.9 (4143.2) -> 4050.9 (4143.2) MB, 11294.8 / 0.0 ms  (average mu = 0.042, current mu = 0.008) allocation failure scavenge might not succeed



    <--- JS stacktrace --->


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

     1: 0x10dadabf5 node::Abort() (.cold.1) [/Users/andyzhou/.nvm/versions/node/v16.15.0/bin/node]

     2: 0x10c7ce349 node::Abort() [/Users/andyzhou/.nvm/versions/node/v16.15.0/bin/node]

     3: 0x10c7ce4bf node::OnFatalError(char const*, char const*) [/Users/andyzhou/.nvm/versions/node/v16.15.0/bin/node]

     4: 0x10c950987 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/Users/andyzhou/.nvm/versions/node/v16.15.0/bin/node]

     5: 0x10c950923 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/andyzhou/.nvm/versions/node/v16.15.0/bin/node]

     6: 0x10caf2005 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users/andyzhou/.nvm/versions/node/v16.15.0/bin/node]

     7: 0x10caf604d v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/Users/andyzhou/.nvm/versions/node/v16.15.0/bin/node]

     8: 0x10caf292d v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/Users/andyzhou/.nvm/versions/node/v16.15.0/bin/node]

     9: 0x10caefe4d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/andyzhou/.nvm/versions/node/v16.15.0/bin/node]

    10: 0x10cafd230 v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/andyzhou/.nvm/versions/node/v16.15.0/bin/node]

    11: 0x10cafd2b1 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/andyzhou/.nvm/versions/node/v16.15.0/bin/node]

    12: 0x10caca347 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/Users/andyzhou/.nvm/versions/node/v16.15.0/bin/node]

    13: 0x10ce81f4e v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/Users/andyzhou/.nvm/versions/node/v16.15.0/bin/node]

    14: 0x10d22ba19 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/Users/andyzhou/.nvm/versions/node/v16.15.0/bin/node]


    Process finished with exit code 134 (interrupted by signal 6: SIGABRT)


    因为增加 的页面的太多了,比如:https://www.zhoulujun.co/

    其实是nodejs 内存溢出,可以改变

    解决办法就是:

    {
      "name": "zhoulujun.co",
      "main": "index.js",
      "scripts": {
        "docs:dev": "vitepress dev docs",
        "docs:build": "vitepress build docs",
        "docs:buildMax": "node --max_old_space_size=8096 ./node_modules/vitepress-zhoulujun/bin/vitepress.js build docs",
        "
      },
     }

    这样就可以解决了

    关键在于:node --max_old_space_size=8096

    vitepress-zhoulujun, 是个人博客打包的过程中优化的内容

    https://www.npmjs.com/package/vitepress-zhoulujun

    https://github.com/zhoulujun/vitepress

     优化的内容有:

    也叫 footer  增加 v-html,可以自定义 也叫。比如增加备案链接与友情链接

    第二个就是  (!) Found dead link  ……………… 无法打包问题


    用 vitepress-zhoulujun 这个包打包就好了,里面增加了我的谷歌广告,可以替换一下




    转载本站文章《vitepress 打包内存溢出: JavaScript heap out of memory》,
    请注明出处:https://www.zhoulujun.cn/html/tools/Bundler/vite/8856.html