How you can tell this is memory leak? I am simply run sqlite query using sqlite3_exec() in c. I hope you get understand the example std::stringstream sql; sql<<"select IFNULL(intTicketTypeID,0),IFNULL(strTicketNo,''),IFNULL(strSubTicketNo,0)" \ ",IFNULL(intFromStationID,0),IFNULL(intToStationID,0),IFNULL(intFullTicketsAmt,0)" \ ",IFNULL(dteTicketDateTime,''),IFNULL(intUserID,0),IFNULL(strCardNumber,''),IFNULL(strCardUID,'')" \ ",IFNULL(intOldBalance,0),IFNULL(intNewBalance,0),IFNULL(intMachineID,0),IFNULL(intRouteID,0)" \ ",IFNULL(intTripID,0),IFNULL(intShiftID,0),IFNULL(intVehicleID,0),IFNULL(intFullTicketsAmt,0)" \ ",IFNULL(intFullTickets,0),IFNULL(intHalfTicketsAmt,0),IFNULL(intHalfTickets,0),IFNULL(dteServiceDate,'')" \ ",IFNULL(intTotalDiscountGiven,0),IFNULL(intHHTicketCategoryID,0),IFNULL(intLessAmount,0)" \ ",IFNULL(strIDProofNo,''),IFNULL(intVehicleTypeID,0),IFNULL(intRouteTypeID,0),IFNULL(strWayBillNo,'')" \ ",IFNULL(intNoofTimesPrinted,0),IFNULL(intTotalGSTCharges,0),IFNULL(intSGSTCharge,0),IFNULL(intCGSTCharge,0)" \ ",IFNULL(intSGSTAdjustmentAmt,0),IFNULL(intCGSTAdjustmentAmt,0),IFNULL(intServiceTypeID,0),IFNULL(intTollAmount,0)" \ ",IFNULL(INTCARDCATEGORYID,0),IFNULL(BSUCCESSTXNFORCARD,0),IFNULL(STRPAYMENTREFNO,0),IFNULL(STRRESPONSECODE,0)" \ " from tblTicketTransactions where bUploaded = 0 and strWayBillNo ='"<<strWaybillNo<<"' and strTicketNo='"<<strTicketNo<<"'and intTripID='"<<strTripID<<"';"; std::string usr_query = sql.str(); char* errMsg=0; DBGF_TRACE("InsertTransaction::GenerateTransactionDataForSDCard::preparePendingTxnString : :usr_query=%s",usr_query); strRowDataBufferFULL.assign(""); result = sqlite3_exec(app::dbmanager::SqliteManager::GetDBInstance()->handle, usr_query.c_str(), &GenerateTransactionDataCallBack, 0, &errMsg); if(result == SQLITE_OK) { app::dbmanager::SqliteManager::GetDBInstance()->closeDatabase(); DBGF_TRACE("InsertTransaction::GenerateTransactionDataForSDCard::GetBufferConcate :=%s",strRowDataBufferFULL); return strRowDataBufferFULL; } else { app::dbmanager::SqliteManager::GetDBInstance()->closeDatabase(); AlertVC.displayError("Error",sqlite3_errmsg(app::dbmanager::SqliteManager::GetDBInstance()->handle)); return "1"; } } } boomer::transaction::TransactionResult SDCardBackUpData::GenerateTransactionDataCallBack(void* NotUsed, int argc, char** argv, char** azColName) { char CheckSum[4]=""; strRowDataBufferFULL.append(std::string(argv[0])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[1])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[2])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[3])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[4])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[5])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[6])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[7])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[8])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[9])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[10])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[11])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(strTicketMachineNo); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[13])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[14])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[15])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[16])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[17])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[18])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[19])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[20])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[21])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[22])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[23])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[24])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[25])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[26])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[27])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[28])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[29])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[30])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[31])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[32])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[33])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[34])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[35])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[36])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[37])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[38])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[39])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[40])); strRowDataBufferFULL.append("#"); strRowDataBufferFULL.append(std::string(argv[0]));//checksum strRowDataBufferFULL.append("#"); //Check_Sum_Generate(strlen(strRowDataBuffer.c_str()),strRowDataBuffer.c_str(),CheckSum); strRowDataBufferFULL.append("^"); //DBGF_TRACE("strRowDataBuffer :=%s",strRowDataBufferFULL); return 0; }