Crashes while fetching data from filepath

The app crashes while trying to fetch data from path/URL (video file stored in documents folder) only for large files (>100 MB).

Device Details: iOS (4.3), iPad 1

  1. URL is perfect (Checked logs)
  2. File exists at that path (checked path)

Note: Crashes on device only.

Below is the code where app crashes:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);

if ([paths count] > 0) 
    {
         filePath = [paths objectAtIndex:0];
         filePath = [filePath stringByAppendingPathComponent:@"Private Documents"];
         filePath = [filePath stringByAppendingPathComponent:@"videos"];
         filePath = [filePath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.mp4",st]];
    }

NSURL *fileUrl=[NSURL fileURLWithPath:filePath];
NSMutableData *Data = [NSMutableData dataWithContentsOfURL:fileUrl];  //CRASHES ON THIS LINE
NSLog(@"Data: %d",[Data length]);

Any comments.

Answers


It seems you are running out of memory.

On the device there is normally far less memory available that your simulator and 100MB is a lot to be storing in RAM. Consider breaking the downloadable files into smaller chunks and deal with them in pieces if you can.

I don't think

You are taking to long time and the app gets killed.

as David suggests unless you are doing this on start up.


Need Your Help

Unable to deploy my project on tomcat where i have deployed previously on glassfish

java jsp tomcat servlets glassfish

I have a project developed on netbeans where i deployed it on glassfish.. But now as i am trying to deploy it on tomcat7. I am facing following exception

How do I get the selected item from drop down list and submit it to my Details view?

c# asp.net ajax asp.net-mvc razor

I have an mvc razor form. What i want is to submit the user's selection from Items dropdown list and navigate to Details view in order to access the chosen item's information.