-
Notifications
You must be signed in to change notification settings - Fork 26
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
Realtime: dispose
method
#128
Conversation
- Explicitly dispose all resources
- Clean state when there are no channels
I recall some comments about this, but some context about why do we want this would be helpful. Also, I couldn't find this method on other client libs. What's the story there? |
Do you mean |
Why would iOS be different than any other library? If there is a memory leak, I guess it's because we keep a live reference to the ARTRealtime instance somewhere we shouldn't, right? |
I would assume so, although I thought Objective-C had quirky GC support. You will have to make your recommendation as I don't know the specifics of memory management with Objective-C |
The quirks of Obj-C/Swift memory management shouldn't affect this case, as far as I can see. Leaks can be caused by exactly the same reasons as in any GCed language (Ruby, Java, etc.), plus cycles, but I don't see a problem of cycles (and if there is, it should be fixed with weak references). @ricardopereira, could you provide the full story for this method? |
Some of the tests were failing with Questionable API usage errors when the Travis server ran all the tests. I digged into it and I found out that some callbacks (e.g.: state event subscriptions) were called after the Another example where I decided to clean the channels and events just for convenience: context("test") {
let options = AblyTests.commonAppSetup()
options.autoConnect = false
let client = ARTRealtime(options: options)
it("one test") {
client.connect()
defer {
// Without dispose
//client.dispose()
client.close()
}
waitUntil(timeout: testTimeout) { done in
client.eventEmitter.on { state, error in
print("1. received state \(state)")
done()
}
}
}
it("second test") {
client.connect()
defer {
// Without dispose
//client.dispose()
client.close()
}
waitUntil(timeout: testTimeout) { done in
client.eventEmitter.on { state, error in
print("2. received state \(state)")
done()
}
}
}
} Result:
|
If this method is used as a test convenience, I'd say it should be kept in the tests, don't you think? Either as an extension or as just a function. There are some other methods (like removeAllChannels) that are not part of the documented API and mainly bloat the API, in my opinion. I think it's really important to keep the interface clean and minimal. |
Agreed. In the case of Ruby there is a convention to document some methods as private APIs, even though they are not private methods, but even in those cases I have kept this to a minimum as the less exposed methods that are not part of the API the better. |
Well, I never have in mind to keep the API interface at the same level from other platforms but it makes sense. I added |
So, I will include @mattheworiordan Just to clarify one thing: if the user closes the connection, should the library clean the |
Well if you look at http://docs.ably.io/client-lib-development-guide/features/#RTN18b and http://docs.ably.io/client-lib-development-guide/features/#RTN18c it states that in suspended or failed states the messages should be marked as failed. As the |
#111