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

**URL:** <https://discuss.elastic.co/t/error-when-build-kibana-from-source-code-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/192132>\
**Category:** Kibana\
**Created:** [July 24, 2019, 8:33pm UTC](https://discuss.elastic.co/t/error-when-build-kibana-from-source-code-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/192132 "2019-07-24T20:33:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasmineL](https://avatars.discourse-cdn.com/v4/letter/j/8797f3/32.png) [@jasmineL](https://discuss.elastic.co/u/jasmineL)\
**Post date:** [July 24, 2019, 8:33pm UTC](https://discuss.elastic.co/t/error-when-build-kibana-from-source-code-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/192132/1 "2019-07-24T20:33:04Z")

</div>

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.

```auto
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!

---

<div class="post-metadata">

**Author:** ![Brandon\_Kobel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_kobel/32/14829_2.png) [@Brandon\_Kobel](https://discuss.elastic.co/u/Brandon_Kobel)\
**Post date:** [July 24, 2019, 9:51pm UTC](https://discuss.elastic.co/t/error-when-build-kibana-from-source-code-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/192132/2 "2019-07-24T21:51:38Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![jasmineL](https://avatars.discourse-cdn.com/v4/letter/j/8797f3/32.png) [@jasmineL](https://discuss.elastic.co/u/jasmineL)\
**Post date:** [July 26, 2019, 6:52am UTC](https://discuss.elastic.co/t/error-when-build-kibana-from-source-code-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/192132/3 "2019-07-26T06:52:57Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Brandon\_Kobel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_kobel/32/14829_2.png) [@Brandon\_Kobel](https://discuss.elastic.co/u/Brandon_Kobel)\
**Post date:** [July 26, 2019, 2:38pm UTC](https://discuss.elastic.co/t/error-when-build-kibana-from-source-code-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/192132/4 "2019-07-26T14:38:15Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![Brandon\_Kobel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_kobel/32/14829_2.png) [@Brandon\_Kobel](https://discuss.elastic.co/u/Brandon_Kobel)\
**Post date:** [July 26, 2019, 2:51pm UTC](https://discuss.elastic.co/t/error-when-build-kibana-from-source-code-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/192132/5 "2019-07-26T14:51:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jasmineL](https://avatars.discourse-cdn.com/v4/letter/j/8797f3/32.png) [@jasmineL](https://discuss.elastic.co/u/jasmineL)\
**Post date:** [July 29, 2019, 8:21pm UTC](https://discuss.elastic.co/t/error-when-build-kibana-from-source-code-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/192132/6 "2019-07-29T20:21:05Z")

</div>

Thanks Brandon.

NODE\_OPTIONS="--max-old-space-size=4096" node script/build.js --release

This finally works! Thanks a lot for your help.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 26, 2019, 8:21pm UTC](https://discuss.elastic.co/t/error-when-build-kibana-from-source-code-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/192132/7 "2019-08-26T20:21:18Z")

</div>

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