How to Fix unrar Out of Memory Error

Encountering an "Out of memory" error when extracting RAR archives with unrar typically points to 32-bit binary memory limitations, massive dictionary sizes used during compression, corrupted archive headers, or actual system resource exhaustion. This guide details the primary causes of this error and provides clear, actionable steps to resolve it on both Linux and Windows environments.

1. Upgrade to a 64-Bit Version of unrar

The most common cause of this error is running a 32-bit build of unrar. A 32-bit process can address a maximum of 2 GB to 4 GB of virtual memory. Modern RAR5 archives can use large compression dictionaries that exceed this limit during extraction.

  • Linux (Debian/Ubuntu): Ensure your package manager pulls the 64-bit version:

    sudo apt update
    sudo apt install unrar

    Check the binary architecture:

    file $(which unrar)

    It should indicate x86-64 or aarch64.

  • Windows: Download the official 64-bit command-line or GUI version of WinRAR/UnRAR from the official developer distribution rather than relying on legacy 32-bit portable utilities.

2. Increase Available Virtual Memory (Swap Space)

If your system physically runs low on RAM, the OS kernel will deny memory allocation requests. Adding temporary swap space on Linux prevents the allocation failure.

  1. Create a 4 GB swap file:
    sudo fallocate -l 4G /swapfile
    sudo chmod 600 /swapfile
    sudo mkswap /swapfile
    sudo swapon /swapfile
  2. Verify the swap is active:
    free -h
  3. Retry the extraction command.

On Windows, increase the paging file size under System Properties > Advanced > Performance Settings > Advanced > Virtual Memory.

3. Verify Archive Integrity

A corrupted archive header can report an absurdly high memory allocation requirement to the unrar utility, triggering an immediate "Out of memory" crash even on systems with abundant RAM.

  • Test the archive for errors without extracting:
    unrar t archive.rar
  • Attempt a repair if errors are detected:
    unrar r archive.rar
  • If downloaded from the internet, verify the file's MD5 or SHA256 checksum against the source to confirm the file is not incomplete.

4. Switch to Alternative Extraction Tools

If the proprietary unrar binary fails, open-source alternatives often manage memory streaming differently and can handle problematic archives.

  • Using 7-Zip: 7-Zip frequently handles high-dictionary RAR archives with lower memory overhead.

    # Linux
    sudo apt install p7zip-full p7zip-rar
    7z x archive.rar
    
    # Modern 7-Zip package on newer distros
    sudo apt install 7zip
    7zz x archive.rar
  • Using unar (The Unarchiver): unar is designed to be resilient against non-standard archive metadata.

    sudo apt install unar
    unar archive.rar

5. Check System Ulimits (Linux)

Ensure that your user shell is not restricted by artificial memory caps via ulimit.

  1. Check your current virtual memory limit:
    ulimit -v
  2. If it returns a numerical value instead of unlimited, remove the cap for your current session:
    ulimit -v unlimited
  3. Run unrar x archive.rar again.