I must be missing something obvious, but how come that the following very simple app that creates 1000 1MB data objects and stores them in an array does work and does not seem to saturate (memory footprint of the app is shown as 1.7MB in Xcode)? This code was tested on an iPad 2 with 1GB of memory and does not crash.
@implementation AppDelegate {
NSMutableArray* datas;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
datas = [NSMutableArray new];
for (int i = 0; i < 1024; i++) {
[datas addObject:[NSMutableData dataWithLength:1024*1024]];
}
return YES;
}
@end
I guess that the question really is if some of the allocations are actually done on the iPad flash memory (instead of RAM), and if anybody has any more details about this?
dataWithLengthcall starts returning nil (I think when it runs out of memory) and theaddObject:call throws an exception.