If i run this command:

XZ_OPT=-9 tar --xz -cvf files/compressed/xz/archive.tar.xz -C files/original/ .

Get this message:

xz: (stdin): Cannot allocate memory
tar: files/compressed/lzma//archive.lzma: Wrote only 4096 of 10240 bytes
tar: Error is not recoverable: exiting now

What type of memory it is? Or how do i set it to make it work.

EDIT: (aditional info)

Total file size that I want to compress: 18.92M

Gzip Bzip2 ZIP - works OK

xz --info-memory:

Total amount of physical memory (RAM):  595 MiB (623116288 B)
Memory usage limit for compression:     Disabled
Memory usage limit for decompression:   Disabled

ulimit -a:

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 2312
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 2312
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
  • 1
    What does xz --info-memory say? And ulimit -a? – Stephen Kitt Jul 30 '15 at 19:20
  • Updated question. – Lajdák Marek Jul 31 '15 at 9:46
  • I need comression setting 9 because this is test... and after set XZ_DEFAULTS=--memlimit=150MiB archive was created but i have this message Adjusted LZMA2 dictionary size from 64 MiB to 4 MiB to not exceed the memory usage limit of 150 MiB - is it ok? Is possible turn off this message? (some parameter for ex. -q as quite or whatever) – Lajdák Marek Jul 31 '15 at 10:46

In man xz, you'll find that -9 requires 674 MiB of memory for compression (and that it's only useful if you're compressing files bigger than 32 MiB). Try adding about this much swap to provide enough virtual memory for the operation (assuming you're using all your current memory for other purposes).


I know this is an old thread , but for a xz -9 there is a memory limit of 13Mib , so if you set it to use --memory=135000000 it should run if you have that much available.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.