0
votes

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) 
        {
            [[self alloc] init];

        }
    }
    return _sharedUploaderThread;
}

plz help me , wer i did the mistake

3

3 Answers

2
votes

You are not assigning the value to _sharedUploaderThread. Do

_sharedUploaderThread = [[self alloc] init];

Since you were not assigning the value, you were leaking.

1
votes

You are not storing the pointer to the allocated object. Think you've ment:

_sharedUploaderThread = [[self alloc] init];
0
votes

You never set _sharedUploaderThread equal to the [[self alloc] init]. Thereby leaking it.