lukeredpath/LRResty — Issue #20: Large file streaming downloads fail 
Author: karnlund
Created: 2011-11-12 08:51:01+00:00
State: open

When using the streaming get method to download a 2.6 gigabyte sized file, LRResty fails with out of memory errors, because it is not releasing each block of data after it is passed to the onData block. I would like to stream the data to an NSFileHandle that is opened for writing.

```
- (void)restyClientWillPerformRequest:(LRRestyClient *)client {
[[NSFileManager defaultManager] createFileAtPath:[self archiveFilePath]
contents:nil
attributes:nil];
self.fh = [NSFileHandle fileHandleForWritingAtPath: [self archiveFilePath]];
}

- (void)requestDataFile {
[[LRResty client] setDelegate:self];
[[LRResty client] get:[self archiveURL]
onData:^(NSData *data, BOOL *cancel) {
[fh writeData:data];
} onError:^(NSError *error) {
[fh closeFile];
}
}
```

malloc: *** mmap(size=2337423360) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug