【发布时间】:2011-09-28 22:36:06
【问题描述】:
Using instruments 我发现了一个关于内存泄漏的奇怪问题。我的应用程序有一个日志机制,它通过应用程序记录事件以及与服务器的整个通信(请求-响应)。每个被写入的事件对象都有一个时间戳。这个时间戳得到如下:
[NSDate descriptionWithLocale:[NSLocale systemLocale]]
使用工具,我看到 descriptionWithLocale 导致泄漏。
下面是代码:
-(id)initEvent:(NSString*)eventStr details:(NSString*)detailsStr{
eventString = [[NSMutableString alloc] initWithString:eventStr];
detailsString = [[NSString alloc] initWithString:detailsStr];
date =[[NSMutableString alloc] init];
NSDate* currentDate = [NSDate date];
NSString *dateDescStr = [currentDate descriptionWithLocale:[NSLocale systemLocale]];
[date appendString:dateDescStr];
return [super init];
谢谢, 亚历克斯。
【问题讨论】:
标签: objective-c memory-leaks nsdate instruments