while(sqlite3_step(selectstmt) == SQLITE_ROW) {
NSInteger primaryKey = sqlite3_column_int(selectstmt, 0);
//Expenseentry* temp=[[[Expenseentry alloc]init]autorelease];
//Expenseentry* temp=[[Expenseentry alloc]init];
temp=nil;
temp=[[Expenseentry alloc]init];
//memory leak here
temp.ID=[NSString stringWithFormat:@"%d",primaryKey];
//memory leak here
int i=1;
@try{
//Expenseentry* temp=[[Expenseentry alloc]init];
//tried this but no luck
NSString *s=[[NSString alloc]initWithFormat:@"%f",sqlite3_column_double(selectstmt, 1)];
temp.amount=s;
[s release];
[arrreturn addObject:temp];
//[temp release];
//if i uncomment this app crashes
//[formatter release];
//printf("\n daata count %d ",[arrreturn count]);
}
@catch(id ex)
{
printf("ooooopssss exception ");
}
i++;
}
我的費用入門級內存泄漏
@interface Expenseentry : NSObject {
NSString *ID;
NSString *amount;
}
@property (nonatomic, retain) NSString *ID;
@property (nonatomic, retain) NSString *amount;
@end
and .m is just
- (void)dealloc {
[ID release];
[amount release]
}
您需要修改的代碼,因爲它被切斷,你可能需要一個更詳細的問題,如您認爲可能會發生泄漏(使用分析器嘗試內置到Xcode中,Cmd + shift + A) – 2010-12-22 13:49:27
@jonathan代碼現在已修復。當我第一次運行它時會起作用,但第二次運行時會顯示內存泄漏。這是顯而易見的原因,因爲我沒有釋放臨時原因,如果我將應用程序崩潰 – saurabh 2010-12-22 13:53:14
我已經測試了上面的代碼儀器和書面評論聲明只是在波紋管它顯示內存泄漏 – saurabh 2010-12-22 13:56:04