One of the more recent apps which we developed had to take photos of confidential documents and eventually upload them to a remote server. Taken photos are stored within the app itself and password encrypted so they are not accessible by a third party in any way.

The encryption is done via RNCryptor library and, since each file is up to 10 MB in size, consumes up to 50 MB of memory. RNCryptor supports ARC and this temporary memory load doesn’t cause any issues. However, our server supports upload of up to 20 files and, when files are decrypted one after another, memory overload accumulates.

In order to solve this, we created a recursive method which decrypts files in background and calls a finish block when there are no more files to decrypt. The same method appends decrypted files to an output file which is later uploaded to server

 

The previous method is called from another method which creates the output file and, since our server accepts files in a JSON list format, appends the start and end of JSON message to the file.

So always keep track of the “Debug navigator”, even if your app is not doing memory intensive tasks. Most often it gives you enough insight to notice lifecycle problems before they cause issues in the app functionality, without the need to launch separate “Instruments” app.