TensorFlowSharp icon indicating copy to clipboard operation
TensorFlowSharp copied to clipboard

Not released memory after all TFcomponents disposed.

Open kbegiedza opened this issue 6 years ago • 0 comments

Describe the bug Memory not deallocated after TFSession / TFGraph / etc. disposed.

To Reproduce Construct & dispose several times following class:

public class DetectionService
{
    private readonly TFGraph _graph;
    private readonly TFStatus _status;
    private readonly TFBuffer _buffer;
    private readonly TFSession _session;
    private readonly TFSessionOptions _options;    

    public DetectionService()
    {
        _graph = new TFGraph();
        _buffer = new TFBuffer(File.ReadAllBytes(modelPath));
        _graph.Import(_buffer);
        _status = new TFStatus();
        _options = new TFSessionOptions();
        _session = new TFSession(_graph, _options);
    }

    public void Dispose()
    {
        _session?.Dispose();
        _graph?.Dispose();
        _buffer?.Dispose();
        _status?.Dispose();
        _options?.Dispose();
        _catalogItems?.Clear();
    }
}

Expected behavior Memory should be deallocated after dispose.

Desktop (please complete the following information):

  • OS: Ubuntu 18.04.3 LTS (Docker)

kbegiedza avatar Nov 29 '19 13:11 kbegiedza