加入 autoreleasepool 自动释放池。防止内存溢出
代码片段如下:
for(i=0; i<[srclength]; i++) {
@autoreleasepool {
unicharc = [srccharacterAtIndex:(NSUInteger)i];
if(isdigit(c)||isupper(c)|islower(c)){
tmp = [NSStringstringWithFormat:@"%@%c",tmp,c];
}elseif((int)c <256){
tmp = [NSStringstringWithFormat:@"%@%@",tmp,@"%"];
if((int)c <16){
tmp =[NSStringstringWithFormat:@"%@%@",tmp,@"0"];
}
tmp = [NSStringstringWithFormat:@"%@%@",tmp,[LZUtilstohex:(int)c]];
}else{
tmp = [NSStringstringWithFormat:@"%@%@",tmp,@"%u"];
tmp = [NSStringstringWithFormat:@"%@%@",tmp,[LZUtilstohex:c]];
}
}
}
网友评论