开发者

iPhone & Mailcore memory leak problem

In the app I'm currently working, I use Mailcore (http://www.mronge.com/m/MailCore/API/) to handle mail server operations. I'm trying to send a message over an SMTP connection in the background. The problem is, Leaks is telling me that I get a decent amount of memory leaks every time a message sends. I'm trying to figure if this is my fault or Mailcore's fault. Here's the code:

From my view controller:

-(void) send_rfq {

    CTCoreMessage *repMsg = [[[CTCoreMessage alloc] init] autorelease];
    NSDate *now = [NSDate date];

    NSString* msgString = [NSString stringWithFormat:@"Date#%@\nRFQ#%@\nSalesRep#%@",[now description], [rfq_entry get_uid],[rfq_entry get_repid]];
    [repMsg setBody:msgString];
    [repMsg setSubject:@"RFQ Assign"];

    [myAppDelegate performSelectorInBackground:@selector(send_msg:) withObject:repMsg];

    [self.navigationController popViewControllerAnimated:YES]; 
}

From my app delegate:

-(BOOL) send_bg:(CTCoreMessage*) msg {
    BOOL success = TRUE;
    @try {
        [CTSMTPConnection sendMessage:msg server:smtp_server username:smtp_uname password:smtp_pass port:smtp_port useTLS:smtp_tls useAuth:smtp_auth];
    }
    @catch (NSException * e) {
        //Msg failed to send;
        success = FALSE;
    }
    return success;
}

-(void) send_msg:(CTCoreMessage*) msg {
   开发者_JS百科 NSAutoreleasePool *pool = [ [NSAutoreleasePool alloc] init];
    [msg setTo:[NSSet setWithObject:[CTCoreAddress addressWithName:@"testaccount" email:rfq_dest]]];
    [msg setFrom:[NSSet setWithObject:[CTCoreAddress addressWithName:@"RFQapp" email:rfq_src]]];
    if(![self send_bg:msg]) {
        UIAlertView * empty_alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Could not send." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [empty_alert show];
        [empty_alert autorelease];
    }
    [pool release];
}


There are no leaks in the code you've posted. Either the leak is a false positive or it's elsewhere in your code. Have you tried profiling your app with Instruments? Have you tried using Build and Analyze to do static analysis of your code?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜