I found the following code in a Unity3D project using the Kinect v2 which I have taken over. I'm paranoid so I thought I'd check before I delete it. But surely there is no reason for these two lines??
colorFrame.Dispose();
colorFrame = null;
This is C#. It has automatic garbage collection so my understanding is that colorFrame will be disposed when its convenient outside of the if(GetRGB) statement
if (GetRGB)
{
ColorFrame colorFrame = frame.ColorFrameReference.AcquireFrame ();
if (colorFrame != null)
{
colorFrame.CopyConvertedFrameDataToArray (_ColorData, ColorImageFormat.Rgba);
_ColorTexture.LoadRawTextureData (_ColorData);
_ColorTexture.Apply ();
colorFrame.Dispose ();
colorFrame = null;
}
}