开发者

Objective C: Memory Leak issue in Class Method

I am hitting the memo开发者_StackOverflow中文版ry leak warning message as seen in the screenshot below.

Objective C: Memory Leak issue in Class Method

I need some advise on how I can resolve this memory leak. 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. Over that _sharedUserStockInfo will remain nil and method will return nil too.


+(UserStockInfo*)shareduserStockInfo{

     @synchronized([UserStockInfo class])
     {

         if(! _sharedUserStockInfo)
             _sharedUserStockInfo= [[self alloc]init];
         return _sharedUserStockInfo; 
     }

     return nil;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜