Jump to content

Not enough memory to compile on OrangePi Zero


gounthar
Go to solution Solved by NicoD,

Recommended Posts

Hi,

 

I think I already know the answer to my question, but I'll ask it anyway.
 

 arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DCYTHON_CLINE_IN_TRACEBACK=0 -I/usr/include/libxml2 -Isrc -Isrc/lxml/includes -I/usr/include/python3.6m -c src/lxml/etree.c -o build/temp.linux-armv7l-3.6/src/lxml/etree.o -w
  arm-linux-gnueabihf-gcc: internal compiler error: Killed (program cc1)

Most of the time, when I get gcc killed on a board, that's because of a lack of memory. I have launched several times the compilation and monitored with htop, and it looks like the memory and swap are full.
I did not fully understand what's going on with the zram and so on, but I think that we can't add swap on the SDCard (which is such a bad idea, I know) on top of this zram.

So, my question is: can we add some more swap, so that I can go to the end of the compilation process?
Thanks.

Link to comment
Share on other sites

See I am a noob at all this. But I found somewhere that these commands can release RAM. Maybe give them a try prior to compiling

/usr/lib/armbian/armbian-ramlog write >/dev/null 2>&1

sync; echo 3 | sudo tee /proc/sys/vm/drop_caches

The first one clears RamLog and the second clears the Buff/Cache.

Try these just for fun.

Or wait for the gurus to give the apt answer

Link to comment
Share on other sites

  • Solution
7 hours ago, gounthar said:

So, my question is: can we add some more swap, so that I can go to the end of the compilation process?

You can create a swap file for this.
If you're using an sd-card then it will be very slow, but it will work. You can use zram and swap files together. It will first use zram, then swap file.
Here is how to create a swapfile. This is for 8GB, if you only need 1GB then use 1GB. When done just reverse the commands and delete /swapfile (sudo rm /swapfile)

sudo fallocate -l 8G /swapfile                Allocate 8GB for swapfile
sudo chmod 600 /swapfile                      Give the correct rights for the swapfile
sudo mkswap /swapfile                         Make it a swapfile
sudo swapon /swapfile                         Turn on the swapfile
sudo nano /etc/fstab                          Open fstab and add the line ...

 /swapfile swap swap defaults 0 0

 

Link to comment
Share on other sites

Note also that many build scripts will attempt to use several cores to speed things up, but the RAM-to-core ratio of SBCs is often not very favourable to this.

 

You can usually add an option on the command line (often -j) to set the number of parallel jobs to run. 1 or 2 is probably more suitable than defaults like 4 or "number of cores" or "number of cores + 1".

 

Link to comment
Share on other sites

6 hours ago, NicoD said:

You can create a swap file for this.
If you're using an sd-card then it will be very slow, but it will work. You can use zram and swap files together. It will first use zram, then swap file.
Here is how to create a swapfile. This is for 8GB, if you only need 1GB then use 1GB. When done just reverse the commands and delete /swapfile (sudo rm /swapfile)


sudo fallocate -l 8G /swapfile                Allocate 8GB for swapfile
sudo chmod 600 /swapfile                      Give the correct rights for the swapfile
sudo mkswap /swapfile                         Make it a swapfile
sudo swapon /swapfile                         Turn on the swapfile
sudo nano /etc/fstab                          Open fstab and add the line ...

 /swapfile swap swap defaults 0 0

This setup works for me, but I use a fast 32Gb SDCARD. I can compile GCC 9.2.0 without failure on this board.

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines