I am hitting the memory leak warning message as seen in the screenshot below.
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With