-
Notifications
You must be signed in to change notification settings - Fork 25
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 issues preventing destroying client #997
Comments
Hi @SpencerCDixon ... we're taking a look for you. Thanks for the detailed report. |
Awesome, let me know if you need me to create a separate reproducible app example or anything. I REALLY wanna get Ably testing in our prod environment asap. Alternatively, if you have an example app of Ably client working with presence channels and computers going to sleep and waking up maybe I'm just using the client completely wrong? |
Thanks, @SpencerCDixon. I've asked @tcard to take a look but he's a little bit stacked at the moment so may not have had time to look in depth. I'm able to check in again on Friday so will endeavour to have a look myself if Toni's not found time or made progress by then. |
Thanks for the detailed report!
Just to clarify, I meant that as a workaround while #984 was pending release. It should be completely OK to keep the same instance across sleeps. About the memory leak issue: I've found a reference cycle which is fixed at #999. While this should definitely be causing a leak on your app, I don't know how what you describe about #1000 fixes another possible situation, which your code may be triggering, but I don't think it's likely. For this to happen, you would have to hold to a reference to Please test if branch
That's weird, but this seems to be an unrelated issue, isn't it? We'll look into it too. |
I'm starting to think this was due to this setting: When I turn wake from sleep off it no longer happens. It's not ideal as the presence will reconcile eventually but I think it will be okay for now. Can let ya know once we have this deployed in the field if it becomes an issue.
I apologize for misunderstanding you! I am now no longer tearing down the entire RealTime object.
I'm going to push forward without deallocating these objects but good work on finding some leak fixes! |
Which version of the Ably SDK are you using?
E.g.
1.1.19
On which platform does the issue happen?
E.g.
macOS 10.14
Are you using Carthage?
0.34.0
Are you using Cocoapods?
No
Which version of Xcode are you using?
11.3
What did you do?
Based on advice given in a previous ticket (#984) @tcard recommended completely destroying my ARTRealtime object and creating new ones when computers go to sleep and wake. I'm having trouble accomplishing this.
The latest release 1.1.19 introduced a new bug where after a computer being asleep for about 60-80 seconds they would all of sudden appear online in the presence set of computer B (even though computer A is completely asleep). EDIT: this was with a TTL of tokens set at 2 minutes.
I'm unable to get a simple RealTime client to create and destruct without setting any callbacks or channels without seeing memory leaks. Here is an example of code that can re-create the problem and fix it:
Broken Memory Leak
Assuming I'm using that callback for the
authCallback
when I destroy the client on sleep and recreate when waking up I get this memory leak:It appears that there may be issues with the scheduled block handler retaining things incorrectly.
If I update my auth callback to non-functioning code I can eliminate the issue:
No Memory Leak
Or even parsing the TokenRequest and assigning it to var on self:
No Memory Leak
Passing your code a reference --> memory leak
It's only when I pass the
complete
block handler a reference to the parsedARTTokenRequest
that things start failing.It's possible I'm doing something very obviously wrong or dumb so please let me know if I am 😄 .
Are there tests of creating and destroying real-time clients without memory leaks??
Edit:
Just wanted to let you know I am calling
close
before setting client to nil to remove. Here are what the logs look like when sleeping:The text was updated successfully, but these errors were encountered: