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

Resources not always disposed #77

Open
jeroenheijmans opened this issue Mar 25, 2020 · 0 comments
Open

Resources not always disposed #77

jeroenheijmans opened this issue Mar 25, 2020 · 0 comments

Comments

@jeroenheijmans
Copy link

In the RestClient.cs there is the following code:

using (var requestWriter = new StreamWriter(request.GetRequestStream()))
{
requestWriter.Write(body);
}

Looking at the source for StreamWriter in .NET Core latest (should be similar in other runtimes) this only closes but does not dispose the inner stream.

It might be prudent to change the start of the code to:

using (var stream = request.GetRequestStream())
using (var requestWriter = new StreamWriter(stream))
{
    requestWriter.Write(body);
}

The specific reason I'm asking for this, is that we're seeing ErrorExceptions with inner SocketExceptions claiming AddressAlreadyInUse (10048) errors. This happens after we send a few thousand SMSs, and seems to indicate that sockets on the host are being consumed faster than they become available. So maybe if we don't wait for the GC to collect the .GetRequestStream(), and instead dispose via a using as I suggest, things might improve.

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