ZstdNet icon indicating copy to clipboard operation
ZstdNet copied to clipboard

Frame requires too much memory for decoding (+ fix)

Open KoalaBear84 opened this issue 8 months ago • 1 comments

I've had some issues with decompression a single file, other went fine.

My fix was the following:

using FileStream fileStreamInput = File.OpenRead("TheInputPath");
using FileStream fileStreamOutput = File.OpenWrite("TheOutputPath");

// This is the fix
IReadOnlyDictionary<ZSTD_dParameter, int> advancedParams = new Dictionary<ZSTD_dParameter, int>([
    new KeyValuePair<ZSTD_dParameter, int>(ZSTD_dParameter.ZSTD_d_windowLogMax, 31)
]);

DecompressionOptions decompressionOptions = new(null, advancedParams);
await using var decompressionStream = new DecompressionStream(fileStreamInput, decompressionOptions);
await decompressionStream.CopyToAsync(fileStreamOutput);

Took the 31 from this ZSTD_WINDOWLOG_MAX_64: https://github.com/facebook/zstd/blob/v1.4.5/lib/zstd.h#L1049

I have no idea what it all means, but I hope it helps someone stuck with the same issue 😃

KoalaBear84 avatar Jun 07 '24 10:06 KoalaBear84