app crashes when capturing screenshots

Hi,

put simply, my application crashes when running the following code:

var screenShot : Texture2D = new Texture2D(Mathf.RoundToInt(Screen.width), Mathf.RoundToInt(Screen.height));
screenShot.ReadPixels(new Rect(0, 0, Mathf.RoundToInt(Screen.width), Mathf.RoundToInt(Screen.height)), 0, 0);
screenShot.Apply();

I also have another script with does grabs the pixels from a renderTexture, this also crashed on mobile.

btw it all runs fine in the editor/desktop.

I will just reply to myself.
I found the problem, it was not the actual taking of the screenshot, but storing them in array that used up all the memory after a while I guess.
Now I resize the screenshots and compress them before storing them in the array, this way I am able to store at least 10 screenshots, which is what i need.