简体   繁体   中英

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);
}
-(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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM