docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Manage memory

    As a Sentis user, you are responsible for calling Dispose on any worker, inputs, and sometimes outputs. Specifically, you must call Dispose on outputs obtained via TakeOutputOwnership, or if you take ownership by calling CompleteOperationsAndDownload.

    Note

    Calling Dispose is necessary to properly free up GPU resources.

    For example:

    public void OnDestroy()
    {
        worker?.Dispose();
    
        // Assuming model with multiple inputs that were passed as a Dictionary
        foreach (var key in inputs.Keys)
        {
            inputs[key].Dispose();
        }
        
        inputs.Clear();
    }
    

    If you get a handle to a tensor via the worker.PeekOutput call, the memory allocator still holds responsibility for that memory, you thus do not need to Dispose of it. For more information on PeekOutput, refer to Get output from a model.

    Additional resources

    • Profile a model
    • Create an engine to run a model
    • Create and modify tensors
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)