Спасибо за ваше решение.Работает отлично.На самом деле причиной утечки была не descriptionWithLocale, а моя собственная реализация правила памяти (было 1 год назад :(). Странно, что инструменты указывали на вызов этого метода .... Посмотрите, как теперь выглядит мой класс:
@implementation EventItem
@synthesize eventString, detailsString, date;
-(id)initEvent:(NSString*)eventStr details:(NSString*)detailsStr{
if((self = [super init])){
self.eventString = [[NSMutableString alloc] initWithString:eventStr];
self.detailsString = [[NSString alloc] initWithString:detailsStr];
self.date =[[NSMutableString alloc] init];
NSDate* currentDate = [NSDate date];
NSString *dateDescStr = [currentDate descriptionWithLocale:[NSLocale systemLocale]];
[date appendString:dateDescStr];
[eventString release];
[detailsString release];
[date release];
}
return self;
}
-(NSMutableDictionary*)eventDictionary{
if(!dictionary)
dictionary = [[NSMutableDictionary alloc] init];
else
return dictionary;
[dictionary setObject:self.date forKey:@"Event"];
[dictionary setObject:self.date forKey:@"Date"];
[dictionary setObject:self.detailsString forKey:@"Details"];
[dictionary setObject:self.eventString forKey:@"EventDescription"];
return [dictionary autorelease];
}
-(void)dealloc{
// NSLog(@"dealloc called in EventItem");
[eventString release];
[detailsString release];
[date release];
[super dealloc];
}
@end
Теперь еще одна проблема, которая у меня возникла, связана с тем, что какое-то изображение загружается через "loadWithContentsOfFile:"
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.rowHeight = OC_CELL_HEIGHT;
self.tableView.backgroundColor = [UIColor clearColor];
UIImage* backgroundImage = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"TableBg" ofType:@"png"]];
UIImageView* background = [[UIImageView alloc] initWithFrame:self.tableView.frame];
background.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
background.image = backgroundImage;
[background sizeToFit];
[backgroundImage release];
[self.tableView setBackgroundView:background];
[background release];
[self.tableView setAutoresizesSubviews:YES];
selectedOCData = nil;
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin;
}
В строке:
UIImage* backgroundImage = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"TableBg" ofType:@"png"]];
просачивается 98%, а самая тяжелаяобратная трассировка составляет 240 КБ. Я приложил скриншот с инструментами для этого. Есть ли проблема не с фактическим вызовом initWithContentsOfFile, а с tableView, который не освобожден правильно? (Мой класс - tableViewController).
Спасибо, Алекс. ![instruments](https://i.stack.imgur.com/enhwj.png)