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 strong ref cycle: Rest.push and Rest.push.admin <-> Rest. #999

Merged
merged 1 commit into from
Mar 6, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Source/ARTPush.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ - (void)deactivate {
NSString *const ARTDeviceTokenKey = @"ARTDeviceToken";

@implementation ARTPushInternal {
ARTRestInternal *_rest;
__weak ARTRestInternal *_rest; // weak because rest owns self
ARTLog *_logger;
ARTPushActivationStateMachine *_activationMachine;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/ARTPushAdmin.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ - (ARTPushChannelSubscriptions *)channelSubscriptions {
@end

@implementation ARTPushAdminInternal {
ARTRestInternal *_rest;
__weak ARTRestInternal *_rest; // weak because rest owns self
ARTLog *_logger;
dispatch_queue_t _userQueue;
dispatch_queue_t _queue;
Expand Down
3 changes: 3 additions & 0 deletions Spec/ObjectLifetimes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ class ObjectLifetimes: QuickSpec {
var realtime: ARTRealtime? = ARTRealtime(options: options)
weak var internalRealtime: ARTRealtimeInternal? = realtime!.internal
weak var internalConn: ARTConnectionInternal? = realtime!.connection.internal
weak var internalRest: ARTRestInternal? = realtime!.internal.rest

waitUntil(timeout: testTimeout) { done in
options.internalDispatchQueue.async {
realtime = nil // Schedule deallocation for later in this queue
expect(internalConn).toNot(beNil()) // Deallocation still hasn't happened.
expect(internalRealtime).toNot(beNil())
expect(internalRest).toNot(beNil())
done()
}
}
Expand All @@ -37,6 +39,7 @@ class ObjectLifetimes: QuickSpec {
options.internalDispatchQueue.async {
expect(internalConn).to(beNil())
expect(internalRealtime).to(beNil())
expect(internalRest).to(beNil())
done()
}
}
Expand Down