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 a few memory leaks related to unreleased slices in observers and metadata arrays #217

Merged
merged 2 commits into from
Apr 26, 2018

Conversation

MrMage
Copy link
Collaborator

@MrMage MrMage commented Apr 21, 2018

No description provided.

@MrMage MrMage mentioned this pull request Apr 23, 2018
36 tasks
Copy link
Member

@timburks timburks left a comment

Choose a reason for hiding this comment

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

Thanks for this! See one comment about throwing errors from Metadata init.

}

public init(_ pairs: [String: String]) {
public init(_ pairs: [String: String]) throws {
Copy link
Member

Choose a reason for hiding this comment

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

If I read this correctly, it seems that init throws only because it calls add(), which throws an error that will never occur in practice (because ownsFields is true). Did I miss another throw or do you expect add() to throw other errors in the future? If not, it seems better to use try! add and not throw from init.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had this before (see 7b4f47d), but decided that it is safer not to rely on add not failing in that context. It is guaranteed to not fail now, but that might change if the implementation of add gets changes. And I think most clients won't have a problem adding the try statement.

Copy link
Member

Choose a reason for hiding this comment

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

SGTM.

@timburks timburks merged commit 600644a into grpc:master Apr 26, 2018
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