I have recently figured out that the screenshot code uses ~140Mb of temp memory when taking a screenshot that results in a 4MB JPEG. So I enclosed my screenshot code in a autoreleasepool as below in SWIFT
autoreleasepool{
UIGraphicsBeginImageContextWithOptions(cgSizeToUse, false, 0)
webView.layer.renderInContext(UIGraphicsGetCurrentContext())
image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
}
But now when I debug, the code inside the autoreleasepool is skipped entirely. This is the only autoreleasepool in my code. Any thoughts on what is ahppening?