# Build throws segfault; Cannot allocate memory

**URL:** <https://travis-ci.community/t/build-throws-segfault-cannot-allocate-memory/959>\
**Category:** Android\
**Tags:** android\
**Created:** [November 17, 2018, 3:09pm UTC](https://travis-ci.community/t/build-throws-segfault-cannot-allocate-memory/959 "2018-11-17T15:09:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nielsbishere](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@Nielsbishere](https://travis-ci.community/u/Nielsbishere)\
**Post date:** [November 17, 2018, 3:09pm UTC](https://travis-ci.community/t/build-throws-segfault-cannot-allocate-memory/959/1 "2018-11-17T15:09:35Z")

</div>

The ubuntu Android environment seems to not be able to allocate memory. When running CMake, it throws the following errors:

```auto
    Segmentation fault
    /bin/sh: 1: /bin/sh: 1: /home/travis/build/OsomiLunar/ocore/cmake/bin/cmake: Cannot allocate memory
    /home/travis/build/OsomiLunar/ocore/cmake/bin/cmake: Cannot allocate memory
    /bin/sh: 1: /home/travis/build/OsomiLunar/ocore/cmake/bin/cmake: Cannot allocate memory
    /home/travis/build/OsomiLunar/ocore/cmake/bin/cmake: error while loading shared libraries: libc.so.6: cannot map zero-fill pages: Cannot allocate memory
    /bin/sh: 1: Cannot fork
    clang++: error: unable to execute command: Segmentation fault
    clang++: error: unable to execute command: Killed

```

At first I thought this was a problem with the API, but it builds fine on my Windows device and Linux VM. What can I do to fix this?  
My build is located [here](https://travis-ci.com/OsomiLunar/ocore/jobs/159279558) and the errors start around line 1575.

---

<div class="post-metadata">

**Author:** ![Nielsbishere](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@Nielsbishere](https://travis-ci.community/u/Nielsbishere)\
**Post date:** [November 21, 2018, 11:19pm UTC](https://travis-ci.community/t/build-throws-segfault-cannot-allocate-memory/959/2 "2018-11-21T23:19:27Z")

</div>

Fixed; disabling parallel build (-j in make) solved it; it ran out of RAM.

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [November 22, 2018, 6:58am UTC](https://travis-ci.community/t/build-throws-segfault-cannot-allocate-memory/959/3 "2018-11-22T06:58:56Z")

</div>

Use `make -j<number of cpus>`. (All Travis builders are 2-core as of this writing but [detection isn’t too hard to write](https://github.com/skvark/opencv-python/pull/144/commits/cf601a1a3866fac52bde2381a7448663acc5a128).)

[Running more jobs than that in parallel won’t have a noticeable effect on build speed anyway as tests show](https://stackoverflow.com/questions/2499070/gnu-make-should-the-number-of-jobs-equal-the-number-of-cpu-cores-in-a-system/18853310#18853310) – while pulling ever more system resources as you could see.

---

<div class="post-metadata">

**Author:** ![Nielsbishere](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@Nielsbishere](https://travis-ci.community/u/Nielsbishere)\
**Post date:** [November 22, 2018, 11:10pm UTC](https://travis-ci.community/t/build-throws-segfault-cannot-allocate-memory/959/4 "2018-11-22T23:10:22Z")

</div>

Thanks, that should speed it up a bit 👌
