ImageView Updates Cause Ram Leak

CarbongripCarbongrip USMember ✭✭
edited November 2017 in Xamarin.iOS

Hello I seem to have a ram leak that occurs whenever I update an ImageView frequently. I use this to screen capture a single window and play it in a ImageView. The code works as I intend it to but it causes a ram leak whenever I include remoteWindowFrame.Image = new NSImage(cgImage, new CGSize(cgImage.Width, cgImage.Height));

Here is the code I use...

Timer frameTimer = new Timer(createSingleWindowShot, null, 0, 1000/60);

private void createSingleWindowShot(Object o)
{
    uint testID = 329;
    // Create an image from the passed in windowID with the single window option selected by the user.
    IntPtr windowImage = CGWindowListCreateImage(CGRect.Null, CGWindowListOption.IncludingWindow, testID, CGWindowImageOption.Default);
    CGImage cgImage = new CGImage(windowImage);
    InvokeOnMainThread(delegate {
        remoteWindowFrame.Image = new NSImage(cgImage, new CGSize(cgImage.Width, cgImage.Height));
    });
}

Answers

Sign In or Register to comment.