PlayableGraph was not disposed

I’m experimenting with the Playables in the beta, and I’ve run up into a little nuisance. If I create a PlayableGraph, I’ll get a warning about it not being disposed when I leave play mode.

Simple reproduction is to put this in an empty scene, enter and exit play mode:

public class TestScript : MonoBehaviour
{
    // Use this for initialization
    private void Start()
    {
        var graph = PlayableGraph.Create();
    }
}

Is there a Dispose method I’ve missed somewhere? PlayableGraph doesn’t have one, and I can’t find anything in the API. The only thing I find googling is some threads about “Playable” not being disposed due to a bug in 5.4, so that’s probably unrelated.

Yes, the PlayableGraphs can leak. You need to call Destroy() on it when finished with it.

Right, thanks!

I assume it wouldn’t be a problem if the graph gets destroyed by closing the game? Or does leaked objects “survive” exiting play mode?

Is this intended design for exiting editor playmode? if so it is the first I’ve seen of in the Unity API.

Yes, it’s intended. Playables are intended to be much lighter weight than UnityObjects, and thus they are not serializable. Destroying them in OnDestroy, OnDisable, OnApplicationQuit, etc… is the way to go (depending on the usage).

Thanks for clarification. As there is a warning about it, I’m sure users will realise this but it needs to be clearly documented in any case.