Error when build Kibana from source code : Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

I am trying to build kibana branch 6.8 from source code with command
node script/build.js --release
And I saw below error at when about finish building.

info [  kibana  ] Running optimizer
│ debg Temporarily installing node.js for linux-x64
│ info Running bin/kibana to trigger the optimizer
│ debg $ ./bin/kibana --env.name=production --logging.json=false --optimize
│ debg   log   [20:19:47.212] [info][plugins-service] Plugin initialization disabled.
│ debg   log   [20:20:11.760] [info][optimize] Optimizing and caching bundles for graph, monitoring, space_selector, login, logout, logged_out, ml, dashboardViewer, apm, maps, canvas, infra, uptime, kibana, stateSessionStorageRedirect, status_page and timelion. This may take a few minutes
│ debg   log   [20:20:11.960] [info][optimize:dynamic_dll_plugin] Started dynamic dll plugin tasks
│ debg Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade caniuse-lite browserslist`
│ debg   log   [20:21:15.071] [info][optimize:dynamic_dll_plugin] Need to compile the client vendors dll
│ debg   log   [20:21:15.087] [info][optimize:dynamic_dll_plugin] Client vendors dll compilation started
│ debg
│ debg <--- Last few GCs --->
   │ debg 
   │ debg [542:0x295cd60]   105756 ms: Scavenge 1299.2 (1419.8) -> 1298.4 (1420.3) MB, 3.6 / 0.0 ms  (average mu = 0.292, current mu = 0.370) allocation failure 
   │ debg [542:0x295cd60]   105763 ms: Scavenge 1299.3 (1420.3) -> 1298.5 (1421.3) MB, 3.2 / 0.0 ms  (average mu = 0.292, current mu = 0.370) allocation failure 
   │ debg [542:0x295cd60]   105770 ms: Scavenge 1299.4 (1421.3) -> 1298.6 (1421.8) MB, 3.9 / 0.0 ms  (average mu = 0.292, current mu = 0.370) allocation failure 
   │ debg 
   │ debg 
   │ debg <--- JS stacktrace --->
   │ debg 
   │ debg ==== JS stack trace =========================================
   │ debg 
   │ debg     0: ExitFrame [pc: 0x2d64608dbe1d]
   │ debg Security context: 0x0cd9eb51e6e1 
   │ debg     1: /* anonymous */ [0x321d0f1565a1] [/home/inkiru/kibana-ext/build/kibana/node_modules/terser/dist/bundle.js:~44] [pc=0x2d6460f27f68](this=0x321d0f1375b9 ,e=0x11d3a19ed1f1 ,n=0x1afd36e826f1 )
   │ debg     2: arguments adaptor frame: 1->2
│ debg     3: /* anonymous */(aka /* anonymous */) [0x3fad766...
│ debg FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
│ debg  1: 0x8dc1c0 node::Abort() [/home/inkiru/kibana-ext/build/kibana/node/bin/node]
│ debg  2: 0x8dc20c  [/home/inkiru/kibana-ext/build/kibana/node/bin/node]
   │ debg  3: 0xad60ae v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/home/inkiru/kibana-ext/build/kibana/node/bin/node]
   │ debg  4: 0xad62e4 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/home/inkiru/kibana-ext/build/kibana/node/bin/node]
   │ debg  5: 0xec3972  [/home/inkiru/kibana-ext/build/kibana/node/bin/node]
│ debg  6: 0xec3a78 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/home/inkiru/kibana-ext/build/kibana/node/bin/node]
   │ debg  7: 0xecfb52 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/home/inkiru/kibana-ext/build/kibana/node/bin/node]
   │ debg  8: 0xed0484 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/home/inkiru/kibana-ext/build/kibana/node/bin/node]
   │ debg  9: 0xed30f1 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/home/inkiru/kibana-ext/build/kibana/node/bin/node]
│ debg 10: 0xe9c574 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/home/inkiru/kibana-ext/build/kibana/node/bin/node]
   │ debg 11: 0x113beae v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/home/inkiru/kibana-ext/build/kibana/node/bin/node]
   │ debg 12: 0x2d64608dbe1d

When I try with ---oss parameter it passed.

Could any body help me see what should I do?

Thank you!

Hey @jasmineL, I'd recommend specifying the --max-old-space-size=4000 argument when building to ensure you have enough heap to build:

node --max-old-space-size=4000 script/build.js --release

Hi Brandon,
Thanks for your reply. I tried your option to increase heap size even to 8192 and it crash again.... Is there any other options to try?
And by the way, is that possible to build installed plugins to kibana package?
Thanks!

Thanks for your reply. I tried your option to increase heap size even to 8192 and it crash again.... Is there any other options to try?

Do you have enough free memory on the computer itself which is building Kibana?

And by the way, is that possible to build installed plugins to kibana package?

I'm not aware of a way to do so, I'll check with others to see if they know of a way.

Also, if you could try using NODE_OPTIONS="--max-old-space-size=4096" node script/build.js --release as well.

Thanks Brandon.

NODE_OPTIONS="--max-old-space-size=4096" node script/build.js --release

This finally works! Thanks a lot for your help.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.