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

Prevent memory leak #92

Merged
merged 2 commits into from
Oct 6, 2023
Merged

Prevent memory leak #92

merged 2 commits into from
Oct 6, 2023

Conversation

YoavGro
Copy link
Contributor

@YoavGro YoavGro commented Oct 5, 2023

Change the TokenGetter to a weak reference to prevent a memory leak in the client.

The client holds the CentrifugeClientConfig which has a strong reference to a CentrifugeConnectionTokenGetter
The problem can happen once the CentrifugeConnectionTokenGetter implementation is the one that is holding a strong reference to the Client.

This creates a circular strong reference Between the App -> Client -> Config -> TokenGetter -> App

Change the TokenGetter to a weak reference to prevent a memory leak in the client
@FZambia
Copy link
Member

FZambia commented Oct 5, 2023

@YoavGro hello, thanks a lot for PR!

What do you think - it seems we better add the same to Subscription tokenGetter?

public var tokenGetter: CentrifugeSubscriptionTokenGetter?

@YoavGro
Copy link
Contributor Author

YoavGro commented Oct 5, 2023

Yep, good idea.
Done

@FZambia FZambia merged commit 2628c8c into centrifugal:master Oct 6, 2023
1 check passed
@FZambia
Copy link
Member

FZambia commented Oct 6, 2023

Thanks! I'll try to make a new release till the end of this week

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

Successfully merging this pull request may close these issues.

2 participants