Skip to content

Commit

Permalink
Merge pull request #31 from yamakiyo/master
Browse files Browse the repository at this point in the history
Fix memory leaks
  • Loading branch information
aclev committed Jun 6, 2014
2 parents ab0ca53 + 5383b15 commit 895a8e5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
13 changes: 7 additions & 6 deletions src/LiveSDK/Library/Internal/LiveConnectClientCore.m
Expand Up @@ -136,12 +136,13 @@ - (void) refreshSessionWithDelegate:(id<LiveAuthDelegate>)delegate
if ([LiveAuthHelper shouldRefreshToken:_session
refreshToken:_storage.refreshToken])
{
authRefreshRequest = [[LiveAuthRefreshRequest alloc] initWithClientId:_clientId
scope:_scopes
refreshToken:_storage.refreshToken
delegate:delegate
userState:userState
clientStub:self];
authRefreshRequest = [[[LiveAuthRefreshRequest alloc] initWithClientId:_clientId
scope:_scopes
refreshToken:_storage.refreshToken
delegate:delegate
userState:userState
clientStub:self]
autorelease];

[authRefreshRequest execute];
}
Expand Down
5 changes: 5 additions & 0 deletions src/LiveSDK/Library/Internal/LiveDownloadOperationCore.m
Expand Up @@ -76,6 +76,11 @@ - (void) operationCompleted
[self.delegate liveOperationSucceeded:self.publicOperation];
}

// LiveOperation was returned in the interface return. However, the app may not retain the object
// In order to keep it alive, we keep LiveOperationCore and LiveOperation in circular reference.
// After the event raised, we set this property to nil to break the circle, so that they are recycled.
self.publicOperation = nil;

self.completed = YES;
}
}
Expand Down
19 changes: 10 additions & 9 deletions src/LiveSDK/Library/Internal/LiveOperationCore.m
Expand Up @@ -227,12 +227,12 @@ - (void) operationFailed:(NSError *)error
if ([_delegate respondsToSelector:@selector(liveOperationFailed:operation:)])
{
[_delegate liveOperationFailed:error operation:publicOperation];

// LiveOperation was returned in the interface return. However, the app may not retain the object
// In order to keep it alive, we keep LiveOperationCore and LiveOperation in circular reference.
// After the event raised, we set this property to nil to break the circle, so that they are recycled.
self.publicOperation = nil;
}

// LiveOperation was returned in the interface return. However, the app may not retain the object
// In order to keep it alive, we keep LiveOperationCore and LiveOperation in circular reference.
// After the event raised, we set this property to nil to break the circle, so that they are recycled.
self.publicOperation = nil;
}

- (void) operationCompleted
Expand Down Expand Up @@ -264,11 +264,12 @@ - (void) operationCompleted
if ([_delegate respondsToSelector:@selector(liveOperationSucceeded:)])
{
[_delegate liveOperationSucceeded:self.publicOperation];
// LiveOperation was returned in the interface return. However, the app may not retain the object
// In order to keep it alive, we keep LiveOperationCore and LiveOperation in circular reference.
// After the event raised, we set this property to nil to break the circle, so that they are recycled.
self.publicOperation = nil;
}

// LiveOperation was returned in the interface return. However, the app may not retain the object
// In order to keep it alive, we keep LiveOperationCore and LiveOperation in circular reference.
// After the event raised, we set this property to nil to break the circle, so that they are recycled.
self.publicOperation = nil;
}
else
{
Expand Down

0 comments on commit 895a8e5

Please sign in to comment.