Mailing List
Home
Forum Home
MySQL General - General MySQL discussion
MySQL++ - Programming with the C++ API to MySQL
MaxDB - Everything about MaxDB, formerly known as SAP DB
ODBC - ODBC with the MySQL Connector/ODBC driver
MySQL on Win32 - Runing MySQL on Windows 9x/Me/NT/2000/XP
Java Help - Mostly related to the MySQL Connector/J driver
Perl - Perl support for MySQL with DBI and DBD::mysql
GUI - MySQL GUI Tools
Announcement
Subjects
Subject: mysql openssl Question
ERROR 1045: Access denied for user: 'root@localhost ' (Using
password: NO)
Update one field with more fields from another table
Subject: Getting Identity after INSERT
ERROR 2002: Can 't connect to local MySQL server through socket
mysql test 4 1 fails with the gis test
Subject: MySQL Cluster Software
Downgrade Mysql from 4 to 3 23
Mysql 4 0 Oracle Stored Procedure Trigger Conversion
Can 't access mysql after kernel upgrade
Executing MySQL Commands From Within C Program
Comparing and writing out BLOBS
Subject: Re: Preventing Duplicate Entries
FULLTEXT query format question
Strange behavior, Table Level Permission
Does the binary log enabling affect the MySQL performances?
mysql:it 's a db not a dbms how it 's possible?!
mysql have same function mthod as Oracle decode()
 
Is method "const ColData Row::at(size_type i) const " leaking memory?

Is method "const ColData Row::at(size_type i) const " leaking memory?

2007-11-21       - By Thunder0

 Back
Reply:     1     2     3     4     5     6     7     8     9  

Hi all,
this is my first message to the list.
I am using valgrind to check my application that is using mysqlpp to access
a mysql DB.

This is the valgrind message I am concerned about:

==22261== Thread 1:
==22261==
==22261== 111 bytes in 6 blocks are definitely lost in loss record 3 of 7
==22261==    at 0x4005628: operator new[](unsigned)
(vg_replace_malloc.c:197)
==22261==    by 0x404B05F: mysqlpp::Row::at(unsigned) const
(const_string.h:123)==22261==    by 0x404B3E6: mysqlpp::Row::operator[](char
const*) const (row.cpp:115)
==22261==    by 0x8061FFD:
btau::DBSession::retrieveLastLinkingitem(std::vector<btau::LinkingItemData,
std::allocator<btau::LinkingItemData> >&) const (DBSession.cpp:590)
==22261==    by 0x8076395:
btau::ApplicationDataLogicManager::saveTimestampAndLinkingItem(btau:
:TimeStampData&)
(ApplicationDataLogicManager.cpp:388)
==22261==    by 0x8089436:
btau::TSUMessageProcessingThread::manageTimeStampsaveRequest(TSURequest*)
(TSUMessageProcessingThread.cpp:526)
==22261==    by 0x8089D6D: btau::TSUMessageProcessingThread::Run()
(TSUMessageProcessingThread.cpp:402)
==22261==    by 0x809F402: Thread::StartThread(void*) (Thread.cpp:106)
==22261==    by 0x369432: start_thread (in /lib/libpthread-2 (See http://ead-2.ora-code.com).4.so)
==22261==    by 0x4126A1D: clone (in /lib/libc-2 (See http://ibc-2.ora-code.com).4.so)

Here is the fragment of my software valgrind is referring to



    mysqlpp::Result res = query.store();
    mysqlpp::Row row;
    if(res.size() > 1){
      std::cout << "ERROR: the query select ID_N,XN,LN,SERIAL_N from
LINKING_ITEM where ID_N = (select max(ID_N) from LINKING_ITEM) returned more
than one record  " << std::endl;
      assert(false);
    }
    for(unsigned int i=0; i < res.size();i++){
      row = res.at(i);
      LinkingItemData retrievedData;
     
      std::string value(row["ID_N"]);// >>>>>> line 590 mentioned in valgrind
message
      retrievedData.setID(StringToValuesConverter::toULong(value));
      value.assign(row["XN"]);
      retrievedData.setXN(value);
      value.assign(row["LN"]);
      retrievedData.setLN(value);
      value.assign(row["SERIAL_N"]);
      retrievedData.setSerialN(StringToValuesConverter::toULong(value));
      value.assign(row["HASH_ALG"]);
      retrievedData.setHashAlg(value);
      value.assign(row["ID_AU_SOURCE"]);
      retrievedData.setIdAuSource(StringToValuesConverter::toULong(value));
      linkingItemList.push_back(retrievedData);
    }


Here is my suspect:

const ColData Row::at(size_type i) const
{
  if (initialized_) {
    const std::string& s = data_.at(i);
    return ColData(s.data(), s.length(), res_->types(i),
      is_nulls_[i]);
  }
  else {
    if (throw_exceptions())
      throw std::out_of_range("Row not initialized");
    else
      return ColData();
  }
}

when the "ColData" copy constructor is invoked, it is like it calls the
const_string copy constructor first, allocating a new buffer and then this
new "const_string" object is initialised by the ColData copy contstructor


  /// brief Copy ctor
  ///
  /// param cd the other ColData_Tmpl object
  ColData_Tmpl(const ColData_Tmpl<Str>& cd) :
  Str(cd.data(), cd.length()),
  type_(cd.type_),
  null_(cd.null_)
  {
  }


I am not sure about this, could you please give me some help?

Many thanks.
--
Email.it, the professional e-mail, gratis per te: http://www.email.it/f

Sponsor:
Fai squillare la PANTERA ROSA sul tuo cellulare: e' in REGALO
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=6613&d=20071121



--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe:    http://lists.mysql.com/plusplus?unsub=mysql@(protected)