iOS常见内存泄漏解决

 

1 OC和CF转化出现的内存警告

CFStringRef cfString = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,(CFStringRef)picDataString,NULL,CFSTR(":/?#[]@!$&’()*+,;="),kCFStringEncodingUTF8);

NSString *baseString = [NSString stringWithString:(NSString *)cfString];

//释放

CFRelease(cfString);

2  Analyze提示:Value stored to "xxx"is never read

iOS常见内存泄漏解决-LMLPHP

 

maxSize这个变量没有被使用,在当前类中搜索maxSize这个变量发现只是被赋值并没有被使用。

解除这个提示:删除或者注视这行代码OK;

3 警告:value stored to value2 during its initialization is never read 

NSMutableArray *datesArray = [[NSMutableArray alloc]init];

datesArray = [_onDemandDictionary objectForKey:key];

出现了stored to 'datesArray' during its initialization is never read改成NSMutableArray *datesArray = nil;

datesArray = [_onDemandDictionary objectForKey:key];

 
04-15 12:04