bool SlaTypeRefDBUtility::getListByWhereClause(list< SlaTypeRefDB >& rows,
string whereClause, OgreError &e, int max)
{
int __rec_count = 0;

EXEC SQL BEGIN DECLARE SECTION;
SlaTypeRefRecord record;
static char query[2000];
EXEC SQL END DECLARE SECTION;

string sSql = " select t.* from sla_type_ref t ";

if(!whereClause.empty())
{
sSql += whereClause ;
}

strcpy(query,sSql.c_str());
SlaTypeRefDB object;
EXEC SQL CONNECT TO 'slmsitjun22@slscvdd1_tcp' AS 'con_1' WITH CONCURRENT TRANSACTION;

EXEC SQL WHENEVER SQLERROR GOTO errexit;
EXEC SQL WHENEVER NOT FOUND CONTINUE;

EXEC SQL PREPARE stm1 from :query;
EXEC SQL DECLARE stm1_c CURSOR FOR stm1;
EXEC SQL OPEN stm1_c;

while(__rec_count != max) {
EXEC SQL FETCH stm1_c into :record;
if(sqlca.sqlcode == SQLNOTFOUND)
break;
object.populateFromRecord( (void*)&record);
rows.push_back(object);
__rec_count++;
}

EXEC SQL close stm1_c;
EXEC SQL free stm1_c;
EXEC SQL free stm1;

EXEC SQL DISCONNECT 'con_1';
EXEC SQL WHENEVER SQLERROR CONTINUE;
return true;

errexit:
EXEC SQL WHENEVER SQLERROR CONTINUE;
DB_ERROR_INIT(e);

EXEC SQL close stm1_c;
EXEC SQL free stm1_c;
EXEC SQL free stm1;
return false;
}

we use the above method to access a table in our Database.
( I have moved the CONNECT/DISCONNECT method inside this method ).
when i run this code with purify, it shows that there is a memory leak in
EXEC SQL CONNECT, informix libraries. is there smthg wrong in they way we invoke the library calls?? please help ..

This is the purify leak information...
MLK: 71856 bytes leaked at 0x1005e6e78
This memory was allocated from:
malloc [rtlib.o]
dgrealloc [iqdiag.c]
_sqinitdiag [glsenvapi.c]
_sqclrca [glsenvapi.c]
chkAPIerr [globinit.c]
CheckAllGlobInit [glsenvapi.c]
MLK: 2760 bytes leaked at 0x10059b898
This memory was allocated from:
malloc [rtlib.o]
get_thread_context [glsextst.c]
CheckOs_th_Init [osasmb.c]
CheckAlltcbInit [glsextst.c]
sqli_connect_open [glsenvapi.c]
bool SlaTypeRefDBUtility::getListByWhereClausestd::list <SlaTypeRefDB,std::allocator<SlaTypeRefDB> >&,std::basic_string<char,std::char_traits<char>,s td::allocator<char> >,OgreError&,int) [SlaTypeRefDBUtility.ec:147]
strcpy(query,sSql.c_str());
SlaTypeRefDB object;
=> EXEC SQL CONNECT TO 'slmsitjun22@slscvdd1_tcp' AS 'con_1' WITH CONCURRENT TRANSACTION;
MLK: 2288 bytes leaked at 0x1005a3548
This memory was allocated from:
malloc [rtlib.o]
get_thread_context [glsextst.c]
CheckAllGlobInit [glsenvapi.c]
CheckAlltcbInit [glsextst.c]
sqli_connect_open [glsenvapi.c]
bool SlaTypeRefDBUtility::getListByWhereClause(std::lis t<SlaTypeRefDB,std::allocator<SlaTypeRefDB> >&,std::basic_string<char,std::char_traits<char>,s td::allocator<char> >,OgreError&,int) [SlaTypeRefDBUtility.ec:147]
strcpy(query,sSql.c_str());
SlaTypeRefDB object;
//EXEC SQL set connection 'con_1';
=> EXEC SQL CONNECT TO 'slmsitjun22@slscvdd1_tcp' AS 'con_1' WITH CONCURRENT TRANSACTION;
MLK: 2040 bytes leaked at 0x1005d6448
This memory was allocated from:
malloc [rtlib.o]
alloc_sqlda_tcb [iqec1.c]
sqli_mt_alloc_osqlda_tcb [glsenvapi.c]
bool SlaTypeRefDBUtility::getListByWhereClause(std::lis t<SlaTypeRefDB,std::allocator<SlaTypeRefDB> >&,std::basic_string<char,std::char_traits<char>,s td::allocator<char> >,OgreError&,int) [SlaTypeRefDBUtility.ec:159]
while(__rec_count != max) {
EXEC SQL FETCH stm1_c into :record;
if(sqlca.sqlcode == SQLNOTFOUND)
=> break;
object.populateFromRecord( (void*)&record);
rows.push_back(object);
__rec_count++;
void SlmTcalImpl::getAllSlaValues(Slm:laInfoSeq_out) [SlmTcalImpl.C:7295]
void POA_Slm::Query::_getAllSlaValues(void*,CORBA_Marsh alInBuffer&,const char*,VISReplyHandler&) [SlmTcal_s.C:698]