Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
UIImageJPEGRepresentation wrapped in Autorelease Pool Test
func Test_JPEGRepresentation_AutoRelease(iterations: Int, compressionRatio: CGFloat,image: UIImage) {
//Gather the initial information
let startReading = report_memory()
print("Memory at start: \(startReading / 1024 / 1024) mb")
//Loop through the number of test iterations specified
for index in 1...iterations {
if let data = UIImageToDataJPEG2(image: image, compressionRatio: compressionRatio) {
//Sample the length of the first result to make sure we are comparing the same size
if index == 1 {
//Report out results
let dataSize = Int(data.count / 1024 / 1024)
print("Data Length: \(dataSize) mb")
}
}
}
let endReading = report_memory()
print("Memory at finish: \(Int(endReading / 1024 / 1024)) mb")
let delta = (Int(Int(endReading) - Int(startReading)) / 1024 / 1024)
print("Memory delta: \(delta) mb")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.