Skip to content

Commit 9fae5d7

Browse files
committed
Update CreateArchiveDialog.xaml.cs
1 parent 31f9dd2 commit 9fae5d7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Files.App/Dialogs/CreateArchiveDialog.xaml.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,12 @@ private long EstimateCompressionMemory()
335335
long dictBytes = GetEffectiveDictionaryBytes();
336336
int threads = Math.Max(1, cpuThreads);
337337

338-
// LZMA2 compression memory per thread:
339-
// Each thread uses: dictionary + dictionary/2 (hash) + ~6 MB overhead
340-
// Reference: 7-Zip source (LzmaEnc.c, Lzma2Enc.c)
341-
long perThread = dictBytes + dictBytes / 2 + 6 * 1024 * 1024;
342-
return perThread * threads;
338+
// LZMA2 compression memory estimation:
339+
// Per encoder instance: ~dictSize * 11.5 + 6 MB
340+
// LZMA2 uses ceil(threads / 2) encoder instances
341+
int numEncoders = (threads + 1) / 2;
342+
long perEncoder = (long)(dictBytes * 11.5) + 6 * 1024 * 1024;
343+
return perEncoder * numEncoders;
343344
}
344345

345346
private long GetEffectiveDictionaryBytes()

0 commit comments

Comments
 (0)