Skip to content

Commit

Permalink
Merge pull request #50 from dotnet-campus/t/lindexi/ByteListMessageSt…
Browse files Browse the repository at this point in the history
…ream

废弃对 ByteListMessageStream 的内存回收策略,原因是回收的对象可能依然被其他模块占用
  • Loading branch information
lindexi authored Dec 15, 2021
2 parents a953961 + 1ce68df commit 13631ca
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/dotnetCampus.Ipc/Utils/IO/ByteListMessageStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,19 @@

namespace dotnetCampus.Ipc.Utils.IO
{
/// <summary>
/// 数组列表的消息,特别定义类型,方便内存分析
/// </summary>
internal class ByteListMessageStream : MemoryStream
{
public ByteListMessageStream(byte[] buffer, int count, ISharedArrayPool sharedArrayPool) : base(buffer, 0,
public ByteListMessageStream(byte[] buffer, int count) : base(buffer, 0,
count, false)
{
_sharedArrayPool = sharedArrayPool;
Buffer = buffer;
}

public ByteListMessageStream(in IpcMessageContext ipcMessageContext) : this(ipcMessageContext.MessageBuffer,
(int) ipcMessageContext.MessageLength, ipcMessageContext.SharedArrayPool)
(int) ipcMessageContext.MessageLength)
{
}

~ByteListMessageStream()
{
_sharedArrayPool.Return(Buffer);
}

private byte[] Buffer { get; }

private readonly ISharedArrayPool _sharedArrayPool;
}
}

0 comments on commit 13631ca

Please sign in to comment.