Jon Wells
Jon Wells

Reputation: 4259

Objective-C Leak

Can anyone tell me why this is method is giving me leaks? I've been looking at it for ages and can't figure out why its leaking. The leaked object is ContactOperations. the EventType is Malloc and Release. I thought the init might be wrong?

Contact Controller

ContactOperations *contactOps = [[ContactOperations alloc] initWithDatabase:database];
if ([contactOps applicationIsOwner])
    [contactOps startOperations];    
[contactOps release];

Instruments says the alloc is giving me the leak...

Contact Operations

ContactOperations
- (id)initWithDatabase:(Database*)aDatabase
{
    if (self = [super init])
    {
        database = [aDatabase retain];
        parameter = [[Parameter alloc] init];
        parameter.database = aDatabase;
        //addressBook = ABAddressBookCreate();
    }
    return(self);
}



-(void)dealloc
{
    [database release];   
    [parameter release];
    //CFRelease(addressBook);
}

Upvotes: 0

Views: 134

Answers (1)

Oleg Trakhman
Oleg Trakhman

Reputation: 2082

-(void)dealloc
{
    [database release];   
    [parameter release];
    //CFRelease(addressBook);
}

You have forgotten [super dealloc]; at the end of - (void) dealloc. You have to call [super dealloc] in order to clear instance variables of ContactOperations' superclass.

Upvotes: 5

Related Questions