FROM : Daniel Child
DATE : Fri Aug 31 19:38:37 2007
Hi All,
I am trying to parse a large file without approximately 300,000 lines
of text. Judging from the console print, the method does go through
all the records, but then the program seems to freeze with a message
"Loading 87348 stack frames", and when I hit cancel to that alert, I
get the EX_BAD_ACCESS error. Because of the way the debugger freezes
(and because it would take years to load 87000 stack frames), I'm
having a terrible time tracing the error.
Critical portions of code below. Thanks for the help.
Daniel
(in main)
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
DataParser *dp = [DataParser parserWithRecordDelim: @"\r"];
NSString *path, *fullPath, *fileName;
NSFileManager *NSFm;
NSMutableArray *theData;
fileName = @"cleaner data.txt";
NSFm = [NSFileManager defaultManager];
path = @"/Users/danielchild/Documents/DATA/";
fullPath = [path stringByAppendingPathComponent: fileName];
theData = [dp parseFileAtPath: fullPath];
[pool release];
return 0;
The parser is created as follows:
+ (DataParser *) parserWithRecordDelim: (NSString *) rd
{
DataParser *dp = [[[DataParser alloc] init] autorelease];
[dp setRecordDelim: rd];
return dp;
}
And the parse file method is this:
- (NSMutableArray *) parseFileAtPath: (NSString *) path
{
NSString *fileAsString, *oneRecord;
NSMutableArray *unparsedRecords = [[[NSMutableArray alloc] init]
autorelease];
fileAsString = [NSString stringWithContentsOfFile: path];
NSScanner *scanner = [NSScanner scannerWithString: fileAsString];
while (![scanner isAtEnd])
{
if ([scanner scanUpToString:recordDelim intoString: &oneRecord])
{
[unparsedRecords addObject: oneRecord];
printf("%s\n", [oneRecord cString]);
}
}
return unparsedRecords;
}
DATE : Fri Aug 31 19:38:37 2007
Hi All,
I am trying to parse a large file without approximately 300,000 lines
of text. Judging from the console print, the method does go through
all the records, but then the program seems to freeze with a message
"Loading 87348 stack frames", and when I hit cancel to that alert, I
get the EX_BAD_ACCESS error. Because of the way the debugger freezes
(and because it would take years to load 87000 stack frames), I'm
having a terrible time tracing the error.
Critical portions of code below. Thanks for the help.
Daniel
(in main)
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
DataParser *dp = [DataParser parserWithRecordDelim: @"\r"];
NSString *path, *fullPath, *fileName;
NSFileManager *NSFm;
NSMutableArray *theData;
fileName = @"cleaner data.txt";
NSFm = [NSFileManager defaultManager];
path = @"/Users/danielchild/Documents/DATA/";
fullPath = [path stringByAppendingPathComponent: fileName];
theData = [dp parseFileAtPath: fullPath];
[pool release];
return 0;
The parser is created as follows:
+ (DataParser *) parserWithRecordDelim: (NSString *) rd
{
DataParser *dp = [[[DataParser alloc] init] autorelease];
[dp setRecordDelim: rd];
return dp;
}
And the parse file method is this:
- (NSMutableArray *) parseFileAtPath: (NSString *) path
{
NSString *fileAsString, *oneRecord;
NSMutableArray *unparsedRecords = [[[NSMutableArray alloc] init]
autorelease];
fileAsString = [NSString stringWithContentsOfFile: path];
NSScanner *scanner = [NSScanner scannerWithString: fileAsString];
while (![scanner isAtEnd])
{
if ([scanner scanUpToString:recordDelim intoString: &oneRecord])
{
[unparsedRecords addObject: oneRecord];
printf("%s\n", [oneRecord cString]);
}
}
return unparsedRecords;
}






Cocoa mail archive

