Skip to content

OGA Memory Leak — Model and Tokenizer Instances Not Disposed #495

@leestott

Description

@leestott

OGA Memory Leak — Model and Tokenizer Instances Not Disposed

Severity: Warning
Component: ONNX GenAI Runtime (OGA)
Reproduction: Run any example to completion — the leak message appears on process exit

OGA Error: 1 instances of struct Generators::Model were leaked.
OGA Error: 1 instances of struct Generators::Tokenizer were leaked.
    Please see the documentation for the API being used to ensure proper cleanup.

In the Whisper scenario, the leak count was higher:

OGA Error: 1 instances of struct Generators::Model were leaked.
OGA Error: 2 instances of struct Generators::Tokenizer were leaked.

Impact: The Foundry Local SDK does not expose a Dispose() or Unload() method for models in the C# API. There is no documented way for application code to release these native resources.

Expected: Either:

  • Expose IDisposable/IAsyncDisposable on the model or manager objects, or
  • Suppress the leak warnings when the SDK is managing the lifecycle, or
  • Document the proper cleanup pattern.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions