When to dispose of a compute buffer

Hi,

I have a material which takes a compute buffer as an input to create a texture. I’m setting the variables of the texture in the update method. if I don’t dispose of the buffer unity gives me garbage collector warnings. I tried to dispose of the buffer after I set the variable of the material. but that just passes an empty buffer. I tried to make the buffer a global variable so that I won’t need to dispose of it and it still gave me the warning. In image effects shaders you dispose of the buffer after the Graphics.Blit() method. is there an equivalent of this method for the material. Or just some way to stop the warning.

thanks in advance.

void Render()
{
        ComputeBuffer buffer = new ComputeBuffer(bufferSize, sizeof(int));
        buffer.SetData(myArray);

        material.SetBuffer("buffer", buffer);

    //I tried disposing of it here but it couldn't pass the information to the shader

}

void Update()
{
    Render();
}

i’ve been doing it inside OnDestroy()