I am working in an ARC auto-converted project.
I have the content of a huge text file (14MB) stored in an NSString *_documentDataString.
Now I have this loop:
- (void)scanParts
{
    NSString *boundary = [boundaryPrefix stringByAppendingString:_header.boundary];
    NSMutableArray *parts = [NSMutableArray array];
    NSInteger currentLocation = [_documentDataString rangeOfString:boundary].location;
    BOOL reachedTheEnd = NO;
    while(!reachedTheEnd)
    {
        NSInteger nextBoundaryLocation = [[_documentDataString substringFromIndex:currentLocation + 1]
                                          rangeOfString:boundary].location;
        if(nextBoundaryLocation == NSNotFound)
        {
            reachedTheEnd = YES;
        }
        else
        {
            nextBoundaryLocation += currentLocation + 1;
            //[parts addObject:[_documentDataString substringWithRange:
              //                NSMakeRange(currentLocation, nextBoundaryLocation - currentLocation)]];
            currentLocation = nextBoundaryLocation;
        }
    }
}
However, I start getting those errors:
 malloc: *** mmap(size=6496256) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
What is going wrong?
I even start getting this error when running this loop:
while(true)
{
    NSInteger nextBoundaryLocation = [[_documentDataString substringFromIndex:currentLocation + 1]
                                          rangeOfString:boundary].location;
}
 
     
     
     
     
    