List:MySQL++« Previous MessageNext Message »
From:weidong shen Date:September 12 2008 7:31am
Subject:Memory will be exhausted when a minor change is made in "multiquery.cpp"
View as plain text  
Hi

1.
I encounted one problem that the memory used by my applicatiion will
increase when calling stored procedure, until the system's memory is no
left. The code is as below.
**
*        mysqlpp::Query query = opDBConnect->query();
        query << "CALL Procedure_Test()";
        StoreQueryResult obResSet = query.store();
        if (obResSet == NULL) {
            return ERROR_FAIL_GET_RESULTSET_MYSQLIMPL;
        }
        *
*        short sIndex = 0;*
*        short sNumber = 0;
        size_t unRowNum = obResSet.num_rows();
        for (size_t i = 0; query.more_results(); ++i) { // how many result
sets in this store
            for (size_t j = 0; unRowNum > j; j++){ // how many rows in this
set
                   sIndex = obResSet[j][0];
                   sNumber = obResSet[j][1];
            }
            obResSet = query.store_next();
        }*
**
 I fund that the memory used by my application will *not* increase if I *delete
*the two instructions:
*                   sIndex = obResSet[j][0];
                   sNumber = obResSet[j][1];*
And the mempory also doesn't increate if *just print* the items like as the
following:
*                   cout << obResSet[j][0];*
*                   cout << obReSet[j][0];*
*                   *
**
2. You can get the same result by running "multiquery.cpp".
a. Execute it without any change.  It just print the items.  The memory
doesn't increase.
b. Add one instruction into below method/function. The memory will increase.
*static void
print_row(IntVectorType& widths, Row& row)
{
 cout << "  |" << setfill(' ');
 for (size_t i = 0; i < row.size(); ++i) {
        long lTmp = row[i];
  cout << " " << setw(widths.at(i)) << row[i] << " |";
 }
 cout << endl;
}*
**
3. So my question is whether my operations are wrong?  And how to get and
parse the result set when calling stored procedure by mysqlpp.  Thinks very
much to read this long mail :)

Thread
Memory will be exhausted when a minor change is made in "multiquery.cpp"weidong shen12 Sep
  • Re: Memory will be exhausted when a minor change is made in "multiquery.cpp"Warren Young13 Sep
Re: Memory will be exhausted when a minor change is made in "multiquery.cpp"weidong shen16 Sep
  • Re: Memory will be exhausted when a minor change is made in "multiquery.cpp"weidong shen16 Sep
  • Re: Memory will be exhausted when a minor change is made in "multiquery.cpp"Warren Young17 Sep