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

♻ Fix Memory Leak Issue #924

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions PushSharp.Google/GcmServiceConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ public async Task Send (GcmNotification notification)
{
var json = notification.GetJson ();

var content = new StringContent (json, System.Text.Encoding.UTF8, "application/json");

var response = await http.PostAsync (Configuration.GcmUrl, content);

if (response.IsSuccessStatusCode) {
await processResponseOk (response, notification).ConfigureAwait (false);
} else {
await processResponseError (response, notification).ConfigureAwait (false);
using (var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json"))
using (var response = await http.PostAsync(Configuration.GcmUrl, content))
{
if (response.IsSuccessStatusCode) {
await processResponseOk(response, notification).ConfigureAwait(false);
} else {
await processResponseError(response, notification).ConfigureAwait(false);
}
}
}

Expand Down Expand Up @@ -212,5 +212,10 @@ static GcmResponseStatus GetGcmResponseStatus (string str)
//Default
return GcmResponseStatus.Error;
}

~GcmServiceConnection()
{
http.Dispose();
}
}
}