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

It looks like memory leak in Utf16ValueStringBuilder.Insert #36

Closed
martynovs opened this issue Dec 5, 2020 · 1 comment
Closed

It looks like memory leak in Utf16ValueStringBuilder.Insert #36

martynovs opened this issue Dec 5, 2020 · 1 comment

Comments

@martynovs
Copy link

Original buffer is not released before assigning new buffer

int remainLnegth = this.index - index;
buffer.AsSpan(index, remainLnegth).CopyTo(newBuffer.AsSpan(newBufferIndex));
buffer = newBuffer;
this.index = newBufferIndex + remainLnegth;
}

For example Grow releases buffer before assigning new one

buffer.CopyTo(newBuffer, 0);
if (buffer.Length != ThreadStaticBufferSize)
{
ArrayPool<char>.Shared.Return(buffer);
}
buffer = newBuffer;
}

@neuecc
Copy link
Member

neuecc commented Jan 14, 2021

thanks, fixed at 2.3.0.

@neuecc neuecc closed this as completed Jan 14, 2021
ThangwLee pushed a commit to WolffunGame/ZString that referenced this issue May 26, 2023
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

2 participants