title: ios load large file use memory mapping failed
body: <p>use below methods to mapping a large file failed.</p>
  
  <pre><code>NSData *mappedData = [NSData dataWithContentsOfFile:self.videoPath options:NSDataReadingMappedAlways error:&amp;error];
  </code></pre>
  
  <p>or map:</p>
  
  <pre><code>int fd = open([path fileSystemRepresentation], O_RDONLY);
  struct stat statbuf;
  if (fstat(fd, &amp;statbuf) == -1) {
      close(fd);
      return nil;
  }
  
  void *mappedFile;
  mappedFile = mmap(0, statbuf.st_size, PROT_READ, MAP_FILE|MAP_SHARED, fd, 0);
  close(fd);
  if (mappedFile == MAP_FAILED) {
      NSLog(@"Map failed, errno=%d, %s", errno, strerror(errno));
      return nil;
  }
  
  // Create the NSData
  NSData *mappedData = [NSData dataWithBytesNoCopy:mappedFile length:statbuf.st_size freeWhenDone:NO];`
  </code></pre>
  
  <p>memory mapping failed , mappedData load whole file to RAM. </p>
  
  <p>why failed? any other suggestion?</p>