What triggers iOS 5.0 cache purge? - iphone

As of iOS 5.0 Apple began to purge or clean the Caches directory inside individual applications when it decided the device was using too much space. Can anyone point me to the location of documentation or anecdotal information regarding at which threshold this cache cleaning occurs (for instance 90%+ disk usage) and how often it is checked?

From my my testing, it seems that the wipe happens to all not currently running applications when the space usage on the device EXCEEDS the reported amount of space available (seems iPhone lies about space available to prevent you from getting into reserved space). When you cross that line, a dialogue pops up:
And when you hit done, it then wipes the space. This is the only situation that I was able to reliably reproduce to trigger the wipe (for testing / etc), and I did so by filling my device as much as I could with movies and music, and then downloading big files in DropBox.

as far as i know there hasn't been any official information about when the purge happens and - to be honest - you shouldn't be trying to predict it. it IS a problem, though. thankfully, apple has realised this and as of iOS 5.0.1 you can set a "do not backup" flag:
http://developer.apple.com/library/ios/#qa/qa1719/_index.html
so you'll want to place those files in your app's Documents/ dir or your apps Library/Private Documents/ and set the "do not backup" attribute.

Related

iCloud Drive take forever to upload. Is there a way to rush "Waiting to upload state"?

I have two 50KB files saved in iCloud Drive. Using FileManager, saved in an iCloud container.
The problem is that they take forever to upload. I waited 2 hours and they are still in this waiting to upload status. Both my iPhone and iPad having this issue.
Is there a way I can force it upload? Or at least put it into priority queue.
I'm building a note app sync feature. And those slow upload makes sync impossible.
I ran into a problem like yours and tried to find the solution. So, I contacted directly to Apple Support.
Here's the suggestion:
First, you have to make sure that your OS version is up to date and your iCloud storage has enough space.
Next, you go to System Preference > Apple ID > uncheck a checkbox in front of iCloud then check it back.

Can the contents of the NSCachesDirectory be deleted by the system while the app is open?

As title.
Is it possible that files that I store in the NSCachesDirectory can be deleted by the system (i.e. in low storage situations), while my is running in the foreground?
File System programming guide
On iOS 5.0 and later, the system may delete the Caches directory on rare occasions when the system is very low on disk space. This will never occur while an app is running. However, you should be aware that iTunes restore is not necessarily the only condition under which the Caches directory can be erased.
So the answer is - No, it is not possible for the NSCachesDirectory to be deleted while the app is running in the foreground.
However their wording is slightly ambiguous with regard to the app running in the background.

MonoTouch: How to set the "do not back up" attribute

I am trying to follow the following guidance from Apple about local file storage. How do I set the "do not back" attribute on files created by my apps in MonoTouch?
Technical docs here, but I can't find this in MonoTouch:
https://developer.apple.com/library/ios/#qa/qa1719/_index.html
Use the "do not back up" attribute for specifying files that should
remain on device, even in low storage situations. Use this attribute
with data that can be recreated but needs to persist even in low
storage situations for proper functioning of your app or because
customers expect it to be available during offline use. This attribute
works on marked files regardless of what directory they are in,
including the Documents directory. These files will not be purged and
will not be included in the user's iCloud or iTunes backup. Because
these files do use on-device storage space, your app is responsible
for monitoring and purging these files periodically."
This is available since MonoTouch 5.2 (and iOS 5.0.1) inside the MonoTouch.Foundation.NSFileManager type, methods SetSkipBackupAttribute and GetSkipBackupAttribute.

Physical memory size limit on a iPhone device - per application

Is there any limit on the physical memory size (file system) one can utilize in a iPhone application. My concern is what if someone keeps on writing some data files in the Documents folders and do not purge it. And the data can be of any size.
The only hard storage limit is that of the total available space on the iOS device.
The scenario you have described is likely reality... there is a feature in the upcoming version of iOS that will assist in managing this issue, but it's still under NDA so cannot be discussed here. (yet)
EDIT: And in iOS 5, on your device you can now go to Settings -> Usage to get a list of all installed apps on your phone/pad/pod and see how much extra space they are consuming. :)
You can use ASL or GTMLogger to manage your log files.
Some links that might be handy for you:
Best Practices for Error Logging and/or reporting for iPhone
objective-c logging best practices

What are the storage limits for iPod/iPad applications?

I'm not talking about binary size. I'm talking about the amount of data that can be written to disk during execution inside of certain directories such as Cache or Documents.
I can't find an easy answer in the XCode documentation, which is to say I can find none at all.
I know there is a limit for the cache directory in the form of "oh hey, your device is crashing now", but I haven't determined the actual number, and I am not sure if the Documents folders or other folders have the same restrictions.
Links and numbers are appreciated!
There is no reference or limitation of disk space once the application has been installed to the iPhone, iPad, or iPod Touch device.
The only limitation would be available disk space (whole disk space available) at time of writing to those directories.