你好,我有这个功能,从文件中获取项目虚拟数据: 问题显示在这些线路:潜在泄漏
NSString *path = [[NSBundle mainBundle] pathForResource: @"StatisticsDataJSON" ofType: @"TXT"];
- 对象的潜在泄漏。
NSMutableDictionary *statisticsResponse = [jsonParser objectWithString:data];
- 的潜在泄漏 - 存储到 'statisticArray'
for (int i = 0; i < statsForDate.count; i++)
{物体的潜在的泄漏 - 存储到 'jsonParser'
for (id key in statisticsResponse)
{物体的潜在的泄漏存储为's'的对象
if (self.statistics==nil)
{
self.statistics = [[NSMutableDictionary alloc]init];
NSString *path = [[NSBundle mainBundle] pathForResource: @"StatisticsDataJSON" ofType: @"TXT"];
NSError *error = nil;
NSString *data = [NSString stringWithContentsOfFile: path
encoding: NSUTF8StringEncoding
error: &error];
//NSLog(@"%@",data);
SBJsonParser *jsonParser = [[SBJsonParser alloc] init];
NSMutableDictionary *statisticsResponse = [jsonParser objectWithString:data];
for (id key in statisticsResponse) {
NSArray *statsForDate = [statisticsResponse objectForKey:key];
NSMutableArray *statisticArray = [[NSMutableArray alloc]init];
for (int i = 0; i < statsForDate.count; i++) {
Statistic *s = [[Statistic alloc]init];
s.locationId = [[statsForDate objectAtIndex:i] objectForKey:@"locationId"];
int value =[[[statsForDate objectAtIndex:i] objectForKey:@"visits"] integerValue];
s.visits = value;
value =[[[statsForDate objectAtIndex:i] objectForKey:@"totalUsers"] integerValue];
s.totalUsers = value;
value= [[[statsForDate objectAtIndex:i] objectForKey:@"uploads"] integerValue];
s.uploads = value;
value = [[[statsForDate objectAtIndex:i] objectForKey:@"downloads"] integerValue];
s.downloads = value;
value = [[[statsForDate objectAtIndex:i] objectForKey:@"apps"] integerValue];
s.apps = value;
[statisticArray addObject:s];
}
[self.statistics setObject:statisticArray forKey:key];
};
}
我发现在ststisticsResponse是自动释放 - 解决问题:
NSMutableDictionary *statisticsResponse = [[jsonParser objectWithString:data]autorelease];
但后来东西SBJsonStreamParserAccumulator.m未能在dealoc功能。
什么问题?
你不使用ARC吗? – borrrden
旧项目 - 不是ARC – Cheese
我建议您更新它。从它的外观来看,写它的人不知道内存管理。无论是那个还是你都没有展示全貌。所有你分配/ init你需要稍后发布。你在做那个吗? – borrrden