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

fix memory leak for issue #47 #104

Merged
merged 4 commits into from
Sep 25, 2019
Merged

fix memory leak for issue #47 #104

merged 4 commits into from
Sep 25, 2019

Conversation

tonyli508
Copy link

@tonyli508 tonyli508 commented Sep 2, 2019

weak self to avoid retaining loop, for fixing memory leak for issue #47

Copy link
Collaborator

@EdSancha EdSancha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead

acceptDispatcher {
if self.doesLogEntry(entry, passFilters: config.filters) {
acceptDispatcher { [weak self] in
if self?.doesLogEntry(entry, passFilters: config.filters) ?? false {
Copy link
Collaborator

@EdSancha EdSancha Sep 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for finding this! I would use

[weak self] in 
guard let self = self else { return } 

That way you don't have to deal with optionals

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, did it.

Copy link
Collaborator

@EdSancha EdSancha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you still rename the variable this to be self After the guard it's alright to keep the name and it's also a standard, in fact, @emaloney initiated this change and was included in Swift 4.2 https://github.com/apple/swift-evolution/blob/master/proposals/0079-upgrade-self-from-weak-to-strong.md
Thank you!

@EdSancha EdSancha merged commit af75940 into emaloney:master Sep 25, 2019
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