2012-10-29 3 views
4

내 앱에 JSONKit을 사용하고 있지만 Xcode 4.5.1로 업그레이드하고 분석을 실행하면 Xcode는 JSONKit 코드에서 가능한 메모리 누수를보고합니다.JSONKit에서 메모리 누수가 발생합니까?

/Users/aleksa.topic/SVN/Apple/iTTChart/trunk/iTTChart/Other Sources/JSONKit.m:682:23: Memory is never released; potential leak of memory pointed to by 'array' (또한 사전에 누출 가능성이 있습니다).

누구나이 경험이 있습니까? 정말 메모리 누수가 발생합니까 아니면 Xcode가 충분히 분석하지 못했습니까?

답변

4

이것은 정적 분석기에서 가양 성입니다. 문제를 해결하기 위해 bug report이 있습니다.

+0

그리고 분석기가 무시 만들 수있는 방법이? – Aleksa

1

((array = [array init]) == NULL)(dictionary == NULL)으로 바꾸고 [array autorelease] 대신 free(array) 함수를 사용하여 수정하십시오. 그것은 수동으로 응축 되었기 때문에 shoult도 수동으로 릴리스 될 수 있습니다.

2

이 부분은 link입니다. -로 표시된 행을 +로 표시된 행으로 YY십시오.

- if((array = [array init]) == NULL) { return(NULL); } 
+ if([array init] == NULL) { free(array); return(NULL); } 

- if(JK_EXPECT_F((array->objects = (id *)malloc(sizeof(id) * array->capacity)) == NULL)) { [array autorelease]; return(NULL); } 
+ if(JK_EXPECT_F((array->objects = (id *)malloc(sizeof(id) * array->capacity)) == NULL)) { free(array); return(NULL); } 

- if((dictionary = [dictionary init]) == NULL) { return(NULL); } 
+ if([dictionary init] == NULL) { free(dictionary);return(NULL); } 

- if(JK_EXPECT_F((dictionary->entry = (JKHashTableEntry *)calloc(1UL, sizeof(JKHashTableEntry) * dictionary->capacity)) == NULL)) { [dictionary autorelease]; return(NULL); } 
+ if(JK_EXPECT_F((dictionary->entry = (JKHashTableEntry *)calloc(1UL, sizeof(JKHashTableEntry) * dictionary->capacity)) == NULL)) { free(dictionary); return(NULL); } 
+0

나는이 메모리 누수가 발생했기 때문에 위양성이 있는지 확실하지 않습니다. 이 수정 프로그램은 누출되지 않습니다. – absessive

관련 문제