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

Need dispose method for clearing resources #108

Closed
shashikantdurge opened this issue Jul 21, 2020 · 4 comments
Closed

Need dispose method for clearing resources #108

shashikantdurge opened this issue Jul 21, 2020 · 4 comments

Comments

@shashikantdurge
Copy link

There were memory leak issues in iOS when using this plugin.
Fixed it after using clearListeners()

No proper guide on freeing the resources.

Can we have dispose method in align with flutter ? where it will clearListeners, destroy, close, disconnect...

@jumperchen
Copy link
Member

The code seem to be there already -

void close() => disconnect();
void disconnect() {
_logger.fine('disconnect');
skipReconnect = true;
reconnecting = false;
if ('opening' == readyState) {
// `onclose` will not fire because
// an open event never happened
cleanup();
}
backoff.reset();
readyState = 'closed';
engine?.close();

which will invoke engine#onClose() to clear all the listeners -
transport.clearListeners();

@shashikantleher
Copy link

close() does not call clearListeners() due to which there was memory leak in iOS.
We have faced this issue in prod, took 2 days to figure out the issue for memory leak which was causing iOS crashes

@jumperchen
Copy link
Member

@shashikantleher you mean transport.clearListeners() was not called or someone else?

@shashikantleher
Copy link

socket.clearListeners()

TheMultii added a commit to TheMultii/MarkdownNotepad that referenced this issue Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants