From 1d592897278b172d8549aa29c3a1f3a4f432a9b9 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Thu, 14 Apr 2022 14:50:17 +0300 Subject: [PATCH] xz: Change the cap of the default -T0 memlimit for 32-bit xz. The SIZE_MAX / 3 was 1365 MiB. 1400 MiB gives little more room and it looks like a round (artificial) number in --info-memory once --info-memory is made to display it. Also, using #if avoids useless code on 64-bit builds. --- src/xz/hardware.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/xz/hardware.c b/src/xz/hardware.c index 2cc3f4f2..3d10edc9 100644 --- a/src/xz/hardware.c +++ b/src/xz/hardware.c @@ -279,15 +279,17 @@ hardware_init(void) // /proc/meminfo as the starting point. memlimit_mt_default = total_ram / 4; +#if SIZE_MAX == UINT32_MAX // A too high value may cause 32-bit xz to run out of address space. // Use a conservative maximum value here. A few typical address space // sizes with Linux: // - x86-64 with 32-bit xz: 4 GiB // - x86: 3 GiB // - MIPS32: 2 GiB - const size_t mem_ceiling = SIZE_MAX / 3; // About 1365 GiB on 32-bit + const size_t mem_ceiling = 1400U << 20; if (memlimit_mt_default > mem_ceiling) memlimit_mt_default = mem_ceiling; +#endif return; }