Search code examples
cmemoryarm

Out of memory allocating bytes


I'm trying to build my software on an ARMv7 board with Arch Linux. Also I build for my software a PGO build. The first build compiles without errors, but the second build crashs than I'm using my profile optimized directory for the build. I got this error message here

cc1: out of memory allocating 66574076 bytes after a total of 148316160 bytes

Currently I have 2GB RAM. I've tried to set my swapfile as big as I can (20G) and also my ulimit is unlimit

$ ulimit -a
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 14879
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 14879
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

But it still not compile and I don't know what I can do additionally here to compile my program.


Solution

  • This happened to me many times during my builds due to either being,

    • Memory is full
    • Disk is full

    I got the same 'couldn't allocate memory' error in both cases. Just check the memory usage from top command to see if all RAM/Swap memory is used.

    Also check the disk usage using df command. e.g df -kh to see your compilation drive is full

    When it comes to memory if it's a 32 bit system max memory will be limited to 2^32 ~ 4GB. See 3GB barrier. Increasing the swap size will not help.

    If it's a 64 bit system, memory limit is high, so other possibility may be a permission issue of the file(s)/folder that compiler/linker is trying to access.