Open ryantstone opened 4 years ago
When you instantiate a Metadata
object manually, it sets ownsFields
to true, causing a call to cgrpc_metadata_array_unref_fields
upon deinit. In theory, this should dereference (and thus deallocate) the slices that seem to be leaked here. Upon a cursory look, I can't figure out why this is not the case. But I can't guarantee that we aren't using the CgRPC API wrong, either.
@MrMage Is there any more information about our usage I can provide to help? I don't want you chasing a rabbit if it has something to do with our implementation.
To be honest, I don't really have time to look into this right now, anyway. The easiest way to check whether it is your code could be to just instantiate a Metadata
object with one pair, then check if the leak still occurs once that object leaves scope.
In that case yes, that is what we are doing and the leak is happening. If there is anything else I can do to help let me know. Thanks.
Question Checklist
Question Subject
Leak in
Metadata
Question Description
When instantiating
Metadata
objects I'm getting a large number of memory leaks, initially we were usingMetadata.add(key:value:)
for passing traits but to verify we created the entire dictionary and passed it to theMetadata
initializer. While investigating the leaks I saw the comment:Does this mean that metadata is expected to display a retain cycle in and that it should be disregarded or more likely point to a misuse of the API? Commenting out the metadata completely gets rid of the leaks.