Skip to main content

Introduction

Yocto builds often compile large components such as LLVM, which require significant memory. Builds may fail with out-of-memory (OOM) errors if sufficient RAM or swap is not available. This section describes methods to increase available system memory and improve build stability.

Increase Swap Space

If your build fails due to OOM errors, increase the swap space to at least 32 GB (recommended: 64 GB). Run the following commands to resize the swap file
sudo su root
swapon --show
swapoff /swapfile
fallocate -l 64G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
free -h

Increase zram

You can also increase compressed in-memory swap (zram) to improve memory usage efficiency
modprobe zram
zramctl /dev/zram0 --algorithm zstd --size "$(($(grep -Po 'MemTotal:\s*\K\d+' /proc/meminfo)/2))KiB"
mkswap -U clear /dev/zram0
swapon --discard --priority 100 /dev/zram0