DNF operations use large amount of RAM and may fail in low-memory environments

, , ,

Problem

The current design of the DNF package manager can cause it to use quite large amounts of memory (into the hundreds of megabytes) for most operations. This can mean that DNF operations fail (due to being killed by the kernel’s out-of-memory handler) in low-memory environments, especially systems or containers with 1GB or less of memory and no swap space.

Cause

This is due to parsing large amounts of repository metadata, and the exact amount of memory used varies over time and between Fedora releases as the metadata in their repositories changes.

Related Issues

Bugzilla report: #1907030

Workarounds

The alternative microdnf command can be used instead of dnf for most operations, and will use less memory. Of course, you somehow need to install it first. If possible, it’s a good idea to include microdnf in the initial deployment package set when deploying to low-memory environments. If it’s not installed, and you cannot install it with dnf, you may need to download the package and install it with rpm -ivh.

Another option is to create and use a swap space (a file, a partition, or a ZRAM device).

1 Like