在我正在使用的应用程序中,我使用Mailcore(http://www.mronge.com/m/MailCore/API/)来处理邮件服务器操作。我正在尝试在后台通过SMTP连接发送消息。问题是,Leaks告诉我每次发送消息时都会收到大量的内存泄漏。我想知道这是我的错还是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];
}
来自我的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 {
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];
}
答案 0 :(得分:1)
您发布的代码中没有泄漏。泄漏是误报,或者是代码中的其他地方。您是否尝试使用仪器分析您的应用程序?您是否尝试过使用Build and Analyze对代码进行静态分析?