7-Zip LZMA2 Dictionary Size Settings Guide

This article explains how 7-Zip configures dictionary size settings for the LZMA2 compression algorithm, detailing the default presets, manual configuration methods, and the relationship between dictionary size and system memory usage. You will learn how dictionary settings impact compression efficiency, how to adjust them via the graphical interface and command line, and how to balance file size reduction with hardware limits.


What Is the LZMA2 Dictionary Size?

The dictionary size in LZMA2 defines the sliding window buffer that the compression algorithm uses to identify matching patterns in data. When 7-Zip analyzes a file, it stores a specific block of previously read data in system memory. If repeating sequences of bytes occur within that window, 7-Zip replaces them with references to the previous data instead of storing the duplicates. A larger dictionary enables the algorithm to find repeating patterns across longer distances, resulting in smaller archive sizes at the expense of higher memory (RAM) usage.


Default Configurations by Compression Level

When you select a compression level in 7-Zip, the software automatically assigns a default dictionary size. For the LZMA2 algorithm, the standard default mappings are:

  • Store (0): 0 MB (No compression applied).
  • Fastest (1): 64 KB
  • Fast (3): 1 MB
  • Normal (5): 16 MB
  • Maximum (7): 32 MB
  • Ultra (9): 64 MB

Selecting a level serves as a baseline, but 7-Zip allows manual overrides without changing the overall compression level setting.


Manual Configuration in the 7-Zip GUI

In the Add to Archive dialog window, 7-Zip allows you to manually select the dictionary size from a drop-down menu:

  1. Set the Archive format to 7z.
  2. Set the Compression method to LZMA2.
  3. Locate the Dictionary size drop-down menu.
  4. Select a size ranging from 64 KB up to 1536 MB (on 64-bit systems).

The interface dynamically displays the Memory usage for Compressing and Memory usage for Decompressing directly beneath the compression parameters. If the selected dictionary size requires more RAM than your system can provide, the values will highlight system resource demand before you start the process.


Manual Configuration via Command Line

For automated scripts and command-line usage (7z.exe or 7za.exe), 7-Zip uses the -md switch to define the dictionary size:

7z a -m0=LZMA2 -md=128m archive.7z input_folder
  • -m0=LZMA2: Specifies LZMA2 as the compression method for stream 0.
  • -md=128m: Configures the dictionary size to 128 megabytes.

Accepted size units include k for kilobytes, m for megabytes, and g for gigabytes (e.g., -md=1g).


Memory Usage Calculations

Dictionary size directly dictates the amount of RAM required to compress and extract files:

  • Decompression RAM: Requires roughly equal memory to the dictionary size itself, plus a small operational overhead. For example, a 64 MB dictionary requires around 66 MB to extract.
  • Compression RAM: LZMA2 requires approximately 10 to 11 times the dictionary size per compression thread, plus buffer allocations.
  • Multi-threading Impact: LZMA2 divides data into chunks and processes multiple streams simultaneously. Increasing the thread count increases total compression memory proportionally (Threads × Dictionary Size Multiplier).

System Architecture Limitations

  • 32-Bit Systems: 32-bit 7-Zip binaries are constrained by the 2 GB to 4 GB virtual address space per process. Consequently, dictionary sizes are typically restricted to a maximum of 128 MB to prevent "Out of Memory" crashes.
  • 64-Bit Systems: 64-bit builds can use dictionary sizes up to 1536 MB, provided the host machine has enough physical RAM to sustain the multi-threaded allocation.