Skip to content

I think I've found a memory leak issue in the AvroConvert.SerializeHeadless functions #163

Description

@LyttleG

What is the bug?
I think I've found a memory leak issue in the AvroConvert.SerializeHeadless functions

Fill up the section or provide code

Why the MemoryStream does not uses 'using' here, while it is used in the static byte[] Serialize(object obj, CodecType codecType) function?

public static partial class AvroConvert { 
/// <summary>
/// Serializes given object to Avro format - <c>excluding</c> header
/// </summary>
public static byte[] SerializeHeadless(object obj, string schema)
{
    MemoryStream resultStream = new MemoryStream(); // Why there is no use of using here?
    var encoder = new Writer(resultStream);
    var schemaObject = Schema.Create(schema);
    var resolver = new WriteResolver();
    var writer = resolver.ResolveWriter(schemaObject);

    writer(obj, encoder);

    var result = resultStream.ToArray();
    return result;
}

Yours,
Gerome

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    issueThis doesn't seem right

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions