File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff 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 ( )
You can’t perform that action at this time.
0 commit comments