0

I'm using the following method of reading a text file one line at a time (1.1 million total lines) and the memory footprint of my app on the simulator grows to the total filesize of the text file (480MB). Do I need to implement an autorelease pool drain to manage the memory consumption?

How to read data from NSFileHandle line by line?

NSString *docDir = [AppSession documentsDirectory];
NSString *csvpath = [docDir stringByAppendingPathComponent:@"/docs/output.csv"];

__block NSUInteger count = 0;

DDFileReader * reader = [[DDFileReader alloc] initWithFilePath:csvpath];
[reader enumerateLinesUsingBlock:^(NSString * line, BOOL * stop) 
{
    count++;      
}];

NSLog(@"FINAL COUNT %i", count);
[reader release];
Community
  • 1
  • 1
VinnyD
  • 3,500
  • 9
  • 34
  • 48

1 Answers1

0

Yes. It would have to be in your DDFileReader class, inside the loop in enumerateLinesUsingBlock:. You cannot correctly do it from the bit of code you have posted here.

Anomie
  • 92,546
  • 13
  • 126
  • 145
  • I added an autorelease pool drain in the while statement and that didn't help. while (stop == NO && (line = [self readLine])) { NSAutoreleasePool * readPool = [[NSAutoreleasePool alloc] init]; block(line, &stop); [readPool drain]; } – VinnyD May 20 '11 at 05:34