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

Resolve memory leak on NativeEngine #1043

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

michaelrevlis
Copy link

@michaelrevlis michaelrevlis commented Oct 20, 2024

Issue Link 🔗

Fixes #832 (Is there a way to 'clean up' socket connection to avoid memory leaks, before attempting to reconnect?)
Fixes #938 (Memory leak when use native engine)
Fixes #995 (if you socket resart many time,cpu is very busy and Forever and ever)

Goals ⚽

According to the Apple document,

The session object keeps a strong reference to the delegate until your app exits or explicitly invalidates the session. If you do not invalidate the session by calling the invalidateAndCancel() or finishTasksAndInvalidate() method, your app leaks memory until it exits.

The URLSession is retained because neither invalidateAndCancel() nor finishTasksAndInvalidate() has been called. Consequently, this leads to memory leaks after initializing a new WebSocket and establishing a connection.

Implementation Details 🚧

Invalidate the NativeEngine's URLSession at WebSocket dealloc.

Unit Test Results: Passed
Screenshot 2024-10-20 at 5 28 56 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant