Knowledge Base:Emerge out of memory

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 Article description::decrease number of parallel compiler processes for some ebuilds.

Check current number of parallel jobs in MAKEOPTS:

Also check EMERGE_DEFAULT_OPTS:

It is OK if EMERGE_DEFAULT_OPTS does not exist.

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:

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.

Chromium
See emerge out of memory

TODO

 * Add link here to the page /etc/portage/package.env.
 * use  for both MAKEOPTS and EMERGE_DEFAULT_OPTS?
 * LDFLAGS="-Wl,--no-keep-memory", Linker uses less memory at the expense of IO, IO should be ioniced -3 and isn't high prio IO like swapping