Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory leak if dont use Delimiter #62

Open
VShawn opened this issue Dec 16, 2019 · 0 comments
Open

memory leak if dont use Delimiter #62

VShawn opened this issue Dec 16, 2019 · 0 comments

Comments

@VShawn
Copy link

VShawn commented Dec 16, 2019

in SimpleTcpClient

_queuedMsg would not get Clear() if none of the msg go with a delimiter

here in this while loop:

while (c.Available > 0 && c.Connected)
{
byte[] nextByte = new byte[1];
c.Client.Receive(nextByte, 0, 1, SocketFlags.None);
bytesReceived.AddRange(nextByte);
if (nextByte[0] == delimiter)
{
byte[] msg = _queuedMsg.ToArray();
_queuedMsg.Clear();
NotifyDelimiterMessageRx(c, msg);
}
else
{
_queuedMsg.AddRange(nextByte);
}
}

if i dont offer a delimiter in my reply, then _queuedMsg will always run AddRange and never get a Clear().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant