以下代码崩溃。基本上我正在访问保存为文件的非常大的字符串(xml - 包含图像数据)...修改它并将其保存为新名称...在分析时我没有看到此代码有任何泄漏。 .. 但是在重复这个过程 20-25 次之后......应用程序在 iphone 3gs 上崩溃,内存警告级别为 3,它也杀死了整个运行的应用程序......我找不到任何地方这个应用程序泄漏导致内存警告....任何建议
NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documents = [paths objectAtIndex:0];
NSString *filename = [NSString stringWithFormat:@"%@.yyy",fileToDuplicate];
NSString *initPath = [documents stringByAppendingPathComponent:filename];
NSString *final = [NSString stringWithFormat:@"%@.yyy",[[alertView textFieldAtIndex:0] text]];
NSString *finalPath = [documents stringByAppendingPathComponent:final];
NSString *newName=[[[alertView textFieldAtIndex:0] text] copy];
NSError *error;
NSString *xml = [[NSString alloc] initWithContentsOfFile:initPath encoding:NSASCIIStringEncoding error:&error] ;
NSString *xml_1=[xml stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"<file_name><name>%@.yyy</name></file_name>",fileToDuplicate] withString:[NSString stringWithFormat:@"<file_name><name>%@.yyy</name></file_name>",newName]];
NSString *xml_2=[xml_1 stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"<property_name>%@</property_name>",fileToDuplicate] withString:[NSString stringWithFormat:@"<property_name>%@</property_name>",newName]];
[xml_2 writeToFile:finalPath atomically:YES encoding:NSASCIIStringEncoding error:&error];
xml=nil;
[xml release];
xml_1=nil;
xml_2=nil;
[self.mTableView reloadData];
fileToDuplicate=@"";
[newName release];
[pool drain];
return ;