0

現在使用しているアプリでは、Mailcore(http://www.mronge.com/m/MailCore/API/)を使用してメールサーバーの操作を処理しています。バックグラウンドでSMTP接続を介してメッセージを送信しようとしています。問題は、メッセージが送信されるたびに、かなりの量のメモリリークが発生することをリークが教えてくれることです。これが私のせいなのか、Mailcoreのせいなのかを理解しようとしています。コードは次のとおりです。

私のビューコントローラーから:

-(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]; 
}

私のアプリデリゲートから:

-(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 {
    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];
}
4

1 に答える 1

1

あなたが投稿したコードに漏れはありません。リークが誤検知であるか、コード内の別の場所にあります。Instruments を使用してアプリのプロファイリングを試みましたか? Build and Analyze を使用してコードの静的解析を試みましたか?

于 2011-01-07T20:29:30.280 に答える