ZstdNet
ZstdNet copied to clipboard
Frame requires too much memory for decoding (+ fix)
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 😃