안녕하세요 프로젝트에 파일에서 더미 데이터를 얻을이 기능이 있습니다 문제는 그 라인에 나와 있습니다잠재적 인 누출
NSString *path = [[NSBundle mainBundle] pathForResource: @"StatisticsDataJSON" ofType: @"TXT"];
- 객체의 잠재적 누출. 의 전위 누설 - 'statisticArray'
for (int i = 0; i < statsForDate.count; i++)
{에 저장된 물체의 전위 누설 -
NSMutableDictionary *statisticsResponse = [jsonParser objectWithString:data];
는 - '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];
을하지만 뭔가 dealoc 기능에 SBJsonStreamParserAccumulator.m에 실패합니다.
무엇이 문제인가? 즉, 참조 된 개체가 기술적으로 "유출"되는 첫 번째 점 때문에 잠재적 인 누출에 대한 경고, 잠재적 누출 다음 줄 에 올
ARC를 사용하지 않습니까? – borrrden
이전 프로젝트 - ARC가 아님 – Cheese
업데이트하는 것이 좋습니다. 그것을 본 사람은 메모리 관리에 대해 전혀 모른다. 그것 또는 당신은 전체 그림을 보여주지 않습니다. 나중에 배포해야하는 모든 것을 alloc/init합니다. 그거하고 있니? – borrrden