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

Memory leak in QSFetchZoneChangesOperation.swift #59

Closed
BlixLT opened this issue Oct 16, 2018 · 1 comment
Closed

Memory leak in QSFetchZoneChangesOperation.swift #59

BlixLT opened this issue Oct 16, 2018 · 1 comment

Comments

@BlixLT
Copy link
Contributor

BlixLT commented Oct 16, 2018

When running with Instruments, they show quite a lot memory leaks. As far as I can tell, they originated from QSFetchZoneChangesOperation.swift. It seems that QSFetchZoneChangesOperation has a strong pointer to CKFetchRecordZoneChangesOperation and CKFetchRecordZoneChangesOperation has a strong pointer to QSFetchZoneChangesOperation in one (or several) of the blocks (completions). And ARC cannot release them. If I add
self.operation = nil
at the end of operation.fetchRecordZoneChangesCompletionBlock:

                if let error = operationError {
                    self.finish(error: error)
                } else if higherModelVersionFound {
                    self.finish(error: NSError(domain: QSCloudKitSynchronizerErrorDomain, code: QSCloudKitSynchronizerErrorCode.higherModelVersionFound.rawValue, userInfo: nil))
                } else if self.isCancelled {
                    self.finish(error: NSError(domain: QSCloudKitSynchronizerErrorDomain, code: QSCloudKitSynchronizerErrorCode.cancelled.rawValue, userInfo: nil))
                } else {
                    self.completion(self.zoneResults)
                    self.finish(error: nil)
                }
                self.operation = nil

then Instruments don't show leaks anymore during fetching changes from cloudkit. Not 100% sure if a pointer to operation is still needed there (my guess is that it is not). So, if not, I suppose that could be a fix for these leaks.

@BlixLT BlixLT mentioned this issue Oct 16, 2018
@mentrena
Copy link
Owner

Fixed in 0.6.7
Thanks!

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