TAR archive has only 20kb when application high load
bail16 opened this issue · 0 comments
bail16 commented
Describe the bug
I have .net framework 4.8 application. I'm building TAR archive from multiple memory streams, everything goes ok when application has low load. After executing performance tests, TAR building crashes. Every package after high load has only 20kb.
Reproduction Code
public class TarArchiveWriter : IArchiveWriter
{
private readonly MemoryStream _memoryStream;
private readonly TarOutputStream _tarOutputStream;
private readonly List<IDisposable> _toDispose = new List<IDisposable>();
public string Extension => "tar";
public TarArchiveWriter()
{
_memoryStream = new MemoryStream();
_tarOutputStream = new TarOutputStream(_memoryStream, Encoding.UTF8);
}
public void Write(string path, string xml)
{
var bytes = Encoding.UTF8.GetBytes(xml);
Write(path, bytes);
}
public void Write(string path, byte[] content)
{
var entry = TarEntry.CreateTarEntry(path);
entry.Size = content.Length;
_tarOutputStream.PutNextEntry(entry);
var binaryWriter = new BinaryWriter(_tarOutputStream);
_toDispose.Add(binaryWriter);
binaryWriter.Write(content);
binaryWriter.Flush();
_tarOutputStream.CloseEntry();
}
public void Write(string path)
{
var entry = TarEntry.CreateTarEntry(path);
_tarOutputStream.PutNextEntry(entry);
}
public byte[] GetResult()
{
_tarOutputStream.Close();
return _memoryStream?.ToArray();
}
public void Dispose()
{
foreach (var disposable in _toDispose)
{
disposable?.Dispose();
}
_tarOutputStream?.Dispose();
_memoryStream?.Dispose();
_toDispose.Clear();
}
}
Steps to reproduce
- Create .net MVC application on framework 4.8
- Run high load, performance tests
- Try to build TAR Archive from memory streams
- Every package has 20kb
Expected behavior
Package should be build properly
Operating System
Windows
Framework Version
.NET Framework 4.x
Tags
Tar
Additional context
No response