How to limit the amount of RAM for cmake on raspberrypi?

Viewed 1422

I am trying to compile a project (tdbot) on raspberry pi but when the compilation reaches 50% the available RAM is exhausted and the OS (Raspbian GNU/Linux 9 (stretch) running on a pi v3, 1GB RAM) kills off the compiler thread which results in an error:

[ 50%] Building CXX object td/CMakeFiles/tdcore.dir/td/telegram/AnimationsManager.cpp.o
make[3]: *** wait: No child processes.  Stop.
make[3]: *** Waiting for unfinished jobs....
make[3]: *** wait: No child processes.  Stop.
CMakeFiles/Makefile2:341: recipe for target 'td/CMakeFiles/tdcore.dir/all' failed
make[2]: *** [td/CMakeFiles/tdcore.dir/all] Error 2
CMakeFiles/Makefile2:86: recipe for target 'CMakeFiles/telegram-bot.dir/rule' failed
make[1]: *** [CMakeFiles/telegram-bot.dir/rule] Terminated
Makefile:162: recipe for target 'telegram-bot' failed
make: *** [telegram-bot] Terminated
./build.sh: line 1:  9784 Terminated              make -j 1 telegram-bot

The same project compiles fine on linux and macos. The exact percentage and file name where the compiler process is killed can vary between builds, i.e. it can be 50% or 51%, etc.

I've configured an 8GB swap file by setting CONF_SWAPSIZE=8192 in /etc/dphys-swapfile (memory usage while at 50% compilation).

free -h
              total        used        free      shared  buff/cache   available
Mem:           875M        825M         30M          0B         20M         16M
Swap:          8.0G        828M        7.2G

But even with 8GB swap memory the compiler process is still killed off at 50%.

I've googled for hours trying to find any compile flags for make or cmake that will reduce the RAM requirement but couldn't find anything.

I've also used make -j 1 in order to only use one kernel but it did not help either.

Any other way to make the compilation succeed?

0 Answers
Related