Skip to content

[Bug]: MediaFile.Read causes severe memory leak when scanning many audio files #20

@LanZhan-Harmony

Description

@LanZhan-Harmony

Bug Description

When scanning a large number of audio files using TagLibSharp2, calling MediaFile.Read(string path) causes memory usage to increase sharply (see attached screenshot). I compared this with the official mono/taglib-sharp, which does not show this behavior.

Image

Steps to Reproduce

  1. Iterate over a directory containing many audio files (MP3/FLAC/WAV/etc).
  2. For each file, call MediaFile.Read(filePath) to read tags/properties.

Expected Behavior

Memory usage should remain stable while scanning many files, comparable to mono/taglib-sharp. Temporary buffers should be released promptly after each file is processed.

Actual Behavior

Memory usage grows rapidly while scanning files and does not drop back promptly, eventually causing high memory pressure. This appears to be a leak or retained large buffers.

TagLibSharp2 Version

v0.6.0

Target Framework

.NET 10.0

Operating System

Windows

Additional Context

Is MediaFileResult.File intentionally an object type rather than the IMediaFile interface? It would be clearer and more ergonomic if File were typed as IMediaFile.
I attempted to call Dispose on result.File when available, but memory usage still grows. This suggests large buffers may be held in memory or that some internal objects are not being released.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions