Knowledge Base:Emerge out of memory

From Gentoo Wiki
Jump to: navigation, search

Symptom

  • Building packages hit an "out of memory" error while emerge something
  • The system became extremely slow because of swap usage while emerge something

Solution

Main idea is to decrease number of parallel compiler processes for some ebuilds.

Check current number of parallel jobs in MAKEOPTS:

user $portageq envvar MAKEOPTS

Also check EMERGE_DEFAULT_OPTS:

user $portageq envvar EMERGE_DEFAULT_OPTS

It is OK if EMERGE_DEFAULT_OPTS does not exist.

Note
When MAKEOPTS="-jN" is used with EMERGE_DEFAULT_OPTS="--jobs K --load-average X.Y" the number of possible tasks created would be up to N*K. Therefore, both variables need to be set with each other in mind as they create up to K jobs each with up to N tasks.

EMERGE_DEFAULT_OPTS cannot be set in /etc/portage/package.env. To override the defaults, specify new values on the command line instead.

Try to lower number of parallel jobs for some packages which usually requires more RAM to compile:

FILE /etc/portage/env/j1.conf
MAKEOPTS="-j1"
NINJAFLAGS="-j1"
FILE /etc/portage/env/j2.conf
MAKEOPTS="-j2"
NINJAFLAGS="-j2"
# dev-lang/rust need little more than 4GB RAM if MAKEOPTS="-j4"
dev-lang/rust           j2.conf

# webkit-gtk needs more than 8GB RAM if MAKEOPTS="-j6"
net-libs/webkit-gtk     j2.conf

# Firefox ESR needs more than 8GB RAM if jobs=6
www-client/firefox      j2.conf

# The Palemoon browser requires 9G minimum to build
www-client/palemoon     j1.conf

# Need more than 8GB RAM if MAKEOPTS="-j6"
mail-client/evolution   j2.conf

Very low memory (single-board computers etc.)

It is not advised to use parallel jobs in either MAKEOPTS nor EMERGE_DEFAULT_OPTS on systems that are low RAM.

Special cases

Chromium

See emerge out of memory

See also

TODO