Daily iOS
Performance and debugging

Memory pressure from large images

You need to show a single 50MB photo on screen. If you just load it with UIImage(contentsOfFile:), how much memory does it take?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

Memory use is set by the decoded size, width times height in pixels at 4 bytes per pixel, not the file size. A 12000×9000 photo turns a 50MB file into about 432MB, enough for one image to push the app past its memory limit and get it killed.

Share a question