简体   繁体   English

Objective-C泄漏

[英]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 . 泄漏的对象是ContactOperations the EventType is Malloc and Release. EventType是Malloc和Release。 I thought the init might be wrong? 我以为init可能是错误的?

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]; 您忘记了[super dealloc]; at the end of - (void) dealloc . - (void) dealloc的末尾。 You have to call [super dealloc] in order to clear instance variables of ContactOperations' superclass. 您必须调用[super dealloc]才能清除ContactOperations的超类的实例变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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