Releasing ComputeBuffer in editor sceneview script.

I’m using such script to run OnRenderImage in scene view, but other mono events like OnDisable, Awake etc don’t get called, hence unable to release compute buffers (OnApplicationQuit seems to work, but its not the right place to release the buffers). Getting flooded with warnings, any ideas how to solve this?

[ExecuteInEditMode]
public class SceneViewCameraProxy : MonoBehaviour
{
    #if UNITY_EDITOR
    private SceneView SceneView;
    private Camera Camera;

    public void OnEnable()
    {
        Camera = GetCamera();

        if (Camera != null)
            UpdateComponents();

        EditorApplication.update += TryUpdate;
    }

    void TryUpdate()
    {
        SceneView    = SceneView.lastActiveSceneView;
        Camera        = GetCamera();

        if (SceneView != null)
            EditorApplication.update -= TryUpdate;
    }

    private Camera GetCamera()
    {
        SceneView = SceneView.lastActiveSceneView;

        if (SceneView == null)
            return null;

        return SceneView.camera;
    }
    private Component[] GetComponents()
    {
        var result = GetComponents<Component>();
        return result;
    }
    private void UpdateComponents()
    {
        var components = GetComponents();
        if (components != null && components.Length > 1)
        {
            var cameraGo = Camera.gameObject;

            for (var i = 0; i < components.Length; i++)
            {
                var c = components[i];
                Type cType = c.GetType();
                var existing = cameraGo.GetComponent(cType) ?? cameraGo.AddComponent(cType);

                //Debug.Log(cType.ToString());

                if (cType.ToString() == "PRenderer" || cType.ToString() == "Camera")
                    EditorUtility.CopySerialized(c, existing);
            }
        }
    }
    #endif
}

Why not release them at the end of the OnRenderImage function?

I guess that could work, though would need to rebuild buffers on each frame.