A new dispose() method for Connection which calls close() but then goes on to remove references to any instances of various Manager and other instances create in relation to a Connection instance.
New close() or static removeInstance for the various Managers and Modules which mainly cancels any Timer and StreamSubscription active in those instances. Then deletes the instance from the static instances maps of each class.
A new removeInstance static method for Connection which can be called in addition to dispose() if the Connection instance was created using getInstance instead of the standard Connection constructor.
I should point out that there is no breaking changes as the above additions can be completely ignored and the package used like it was so far. The close() method of Connection remains unchanged.
I added a description to dispose() to indicate it is not a replacement for `close()' and is not suitable when the connection is expected to be re-used later.
@vukoye Hopefully the above makes sense but you may have another idea so would love to hear it. I'm not sure all of the additions are strictly necessary but I found it quite difficult to pinpoint which active references was keeping the Connection instances from being garbage collected. What I know for sure is that after calling dispose() my connections get properly garbage collected.
Here is my answer to https://github.com/vukoye/xmpp_dart/issues/59
A new
dispose()
method for Connection which callsclose()
but then goes on to remove references to any instances of various Manager and other instances create in relation to a Connection instance.New
close()
or staticremoveInstance
for the various Managers and Modules which mainly cancels anyTimer
andStreamSubscription
active in those instances. Then deletes the instance from the staticinstances
maps of each class.A new
removeInstance
static method forConnection
which can be called in addition todispose()
if theConnection
instance was created usinggetInstance
instead of the standardConnection
constructor.I should point out that there is no breaking changes as the above additions can be completely ignored and the package used like it was so far. The
close()
method ofConnection
remains unchanged.I added a description to
dispose()
to indicate it is not a replacement for `close()' and is not suitable when the connection is expected to be re-used later.@vukoye Hopefully the above makes sense but you may have another idea so would love to hear it. I'm not sure all of the additions are strictly necessary but I found it quite difficult to pinpoint which active references was keeping the Connection instances from being garbage collected. What I know for sure is that after calling dispose() my connections get properly garbage collected.