2
votes

I am trying to use image files with my app. These image files are compressed in a .zip-file which is opened from the user from the Mail App or Safari. The .zip-file (which contains the image files) is then unzipped by "SSZipArchive". This works without any problem for smaller files (e.g. 5 images, 10KB). But for bigger files (1900 images, 20MB) the app crashes and it is hard to figure out why because it only crashes when the app is not debugging and not watched by Instruments. A few times I got a crash while using the debugger but only when I opened the .zip-Archive from the Mail App. I then got the message "App terminated due to memory pressure".

Please help!

2
Have you tried to wrap unzipping code over by @autorelease? - Sega-Zero
Have you tried NOT to put the images into a zip? Compressing a jpg or png is just a waste of time and, as you see with your unzipping, a waste of memory. - ott--
@Sega-Zero: I am using ARC. - TomWayne
@ott: What do you mean? How should the user be able to import 2000 pictures more comfortable? - TomWayne
Sorry, I meant @auotoreleasepool. Using ARC does not set you free of memory management. If you have an intense memory allocation inside a cycle - you will run out of memory before unused memory will be deallocated. @autoreleasepool block will shorten a lifetime of unused objects. Try it out, this may save your day. - Sega-Zero

2 Answers

2
votes

You're probably testing on the Simulator. That's never reliable, because your computer has lots of memory! Test on the device to find out under real-life conditions whether your app uses too much memory. If it does, you'll get a warning and then (if you don't do something about the problem) a deliberate termination.

0
votes

The root of your problem is that you simply cannot allocate that much memory under iOS or your app/device will crash. A good rule of thumb is that you app might take 10 to 20 megs of memory while running normally, but if it jumps up to 40-80 at any point then you will be in danger of a crash. You should read up on how much memory images use when decompressed under iOS mem blog post and rework your code to make sure things stay in the 10 to 20 meg of memory usage range.