Memory Leak with creating a new Textrure2D

Hi all, simply making a new project and attaching the following code to a gameobject:

float time = 0;
void Update()
{
    time += Time.deltaTime;
    if(time >= .5f)
    {
        time = 0;
        Texture2D screenShot = new Texture2D((int)1000, (int)1000, TextureFormat.RGBA32, false);
    }
}

Anyone know why this makes the memory continuously increase? As far as I can tell, you cannot deallocate a Texture2D’s memory – it handles itself if it is not referenced by anything. The previous “screenshot” is not referenced by anything after the next iteration of the Update loop.

So I looked more into this and Texture2Ds are not automatically handled if they do not have a reference! However, you can reallocate the memory by using, “Texture2D.Destroy();”. Hope this saves someone time in the future.

Textures are Resources, please Resources.UnloadUnusedAssets() or Unload that particular Resource manaully using Resources.UnloadAsset().