[英]Objective C: Memory Leak issue in Class Method
I am hitting the memory leak warning message as seen in the screenshot below.我正在点击 memory 泄漏警告消息,如下面的屏幕截图所示。
I need some advise on how I can resolve this memory leak.我需要一些关于如何解决此 memory 泄漏的建议。 Can I just do a [self release] at the end of the method?我可以在方法结束时做一个 [自我释放] 吗?
You are not assigning the object returned to _sharedUserStockInfo
so you are losing reference and leaking.您没有分配返回给_sharedUserStockInfo
的 object,因此您正在丢失参考和泄漏。 Over that _sharedUserStockInfo
will remain nil
and method will return nil
too.在那个_sharedUserStockInfo
将保持为nil
并且方法也将返回nil
。
+(UserStockInfo*)shareduserStockInfo{
@synchronized([UserStockInfo class])
{
if(! _sharedUserStockInfo)
_sharedUserStockInfo= [[self alloc]init];
return _sharedUserStockInfo;
}
return nil;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.