This problem has been killing me. There seems to be a problem with loading files in our release application. When looking at the logs closely one of our theories is that we’re opening too many files. So We decided to test this to determine what the limit is on number of open files.
In the applicationDidFinishLaunching I’m creating a bunch of leaky files like so:
// TODO REMOVE
NSLog(@"-----------LOAD LEAKY FILES------------");
NSFileManager *filemgr;
filemgr = [NSFileManager defaultManager];
@try {
for(int i = 0; i < 1100; ++i) {
NSString* iToString = [NSString stringWithFormat:@"assets/%d", i];
NSString* assetPath = [[NSBundle mainBundle] pathForResource: iToString ofType:@"png"];
FILE *f = fopen([assetPath cStringUsingEncoding:1], "r");
if(f == NULL)
NSLog(@"%@", [assetPath stringByAppendingString:@" not found"]);
else
NSLog(@"%@", [assetPath stringByAppendingString:@" found"]);
}
}
@catch (NSException *exception) {
NSLog(@"%@", exception.reason);
}
@finally {
}
// END TODO
Once the application fully loads, I proceed to do clean file I/O that simulates production. This will open an image, close and image etc… While we haven’t figured out what the file limit is; XCode will eventually disconnect and the application gets minimized. As a result we get no error logs to look at and aren’t able to make any headway.
I have a general exception breakpoint set but nothing hits it. Really struggling to figure out how to debug this problem.