2

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.

Elec
  • 53
  • 1
  • 7

2 Answers2

2

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.

SajithP
  • 592
  • 8
  • 19
  • That's why I'm confused, because I have a 20G swap file. The total RAM is used but for the swapfile only 2G are used and than it crashs with the given error above. `df -kh` shows me that I have 24G free space left on my compilation drive. – Elec Aug 10 '17 at 07:22
  • 1
    I'm not sure if you system is a 32-bit. If that's the case, then your most accessible level of memory could be 2G RAM + 2G Swap. If it's a 64 bit system there won't be such issue. If it's a 64-bit system and still the issue persists, then other possibility is a permission problem in somewhere in the accessed files/folders. I will edit the answer to include this information too. – SajithP Aug 10 '17 at 11:10
  • 1
    It is a 32 Bit system. What I've done now was: Crosscompile this on a 64Bit system and also build my performance test with a toolchain and than copied this on the board and start my measures. Thanks for your help! – Elec Aug 10 '17 at 12:43
  • Thanks for accepting my answer. Hope you will succeed in your work :) – SajithP Aug 10 '17 at 23:23
0

I encountered a similar problem in Ubuntu, except that the problem occurred in compiling a C++ program with a MAKEFILE.

According to my searches, i realized that probably the problem is using of 32-bit system or virtual machine.

I found an easy way to get rid of this problem and it is delete the existing binary file from the previous compile.

That worked for me.

Saam
  • 75
  • 8