我在我的app中使用了很少的函数。在每个函数中都有一些本地的String变量。我的函数被多次调用,例如.100函数示例
-(void)getData
{
if(result==1)
{
NSString *componentid=[NSString stringWithFormat:@"%@",subcomponent.componentid];
NSString *componentsubclientid=[NSString stringWithFormat:@"%@",subcomponent.componentsubclientid];
NSString *componentClientid=[NSString stringWithFormat:@"%@",subcomponent.componentClientid];
NSString *componentEntityid=[NSString stringWithFormat:@"%@",subcomponent.componentEntityid];
NSString *componentWorkorderid=[NSString stringWithFormat:@"%@",subcomponent.componentWorkorderid];
NSString *componentStatus=[NSString stringWithFormat:@"%ld",(long)subcomponent.componentStatus];
NSString *notes=[NSString stringWithFormat:@"%@",subcomponent.componentNotes];
NSString *componentAllImages=[NSString stringWithFormat:@"%@",subcomponent.componentAllImages];
NSString *componentAllImagesTime=[NSString stringWithFormat:@"%@",subcomponent.componentAllImagesTime];
//after some code
componentinspectionid=nil;
inspectorid=nil;
componentid=nil;
componentsubclientid=nil;
componentClientid=nil;
componentEntityid=nil;
componentWorkorderid=nil;
componentStatus=nil;
notes=nil;
componentAllImages=nil;
componentAllImagesTime=nil;
}
}
请指导我。Will above code increase the memory ?
如果是,那么编写代码的最佳解决方案是什么,以便内存不会增加。
答案 0 :(得分:1)
没有你的代码似乎不会增加内存。第二件事ARC
在使用后自动清除局部变量或引用。所以,根据我不存在记忆问题的可能性。希望这会有所帮助:)