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