Memory Leaks in Class method objective -c
i had a problem with memory leak in this below code , potential leak of an object in line 39,
and here line 39 is ,[self alloc] init];
+ (UploaderThread *)sharedUploaderThread {
@synchronized(self) {
if (_sharedUploaderThread == nil开发者_JS百科)
{
[[self alloc] init];
}
}
return _sharedUploaderThread;
}
plz help me , wer i did the mistake
You are not assigning the value to _sharedUploaderThread
. Do
_sharedUploaderThread = [[self alloc] init];
Since you were not assigning the value, you were leaking.
You are not storing the pointer to the allocated object. Think you've ment:
_sharedUploaderThread = [[self alloc] init];
You never set _sharedUploaderThread equal to the [[self alloc] init]. Thereby leaking it.
精彩评论