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

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

Open
LyttleG opened this issue May 11, 2024 · 1 comment
Labels
issue This doesn't seem right

Comments

@LyttleG
Copy link

LyttleG commented May 11, 2024

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

@AdrianStrugala AdrianStrugala added the issue This doesn't seem right label May 13, 2024
@AdrianStrugala
Copy link
Owner

Hey,
Thank you for reporting the bug. I will take care of that.
Best,
Adrian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants