Hello how to free gpu ram after taking a photo. when reached ~1000 photos my computer is stuck because I used all the gpu ram.
for now I am using the code below to create a photo:
IEnumerator takePhoto(string filename){
yield return new WaitForEndOfFrame();
// Debug.Log(gameObject.name + " Save Color Photo");
Texture2D screenImage = new Texture2D(Screen.width, Screen.height);
//Get Image from screen
screenImage.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
screenImage.Apply();
//KOKO
//Convert to png
byte[] imageBytes = screenImage.EncodeToPNG();
//Save image to file
System.IO.File.WriteAllBytes(filename + "_scene.png", imageBytes);