List:MySQL++« Previous MessageNext Message »
From:Chris Frey Date:January 27 2006 12:30am
Subject:Re: plz help me.. there is a memory leak..
View as plain text  
On Thu, Jan 19, 2006 at 08:29:40PM +0900, ??? ?????? wrote:
> 
>   mysqlpp::Query query = g_dbcon.query();
> 
>   for(int j=0;j<100000;j++){
> 
>           try{    
>             
>             std::string sql = "insert into table_name \
>                      
> (column_a,column_b,column_c,column_d,column_e,column_f,column_g) \
>                       values(%0q, %1q, %2q, %3q, '%4,%5', %6q)";
>             query << sql; 
>             query.def[(unsigned int)0] = "a";
>             query.def[(unsigned int)1] = "b";
>             query.def[(unsigned int)2] = "c";
>             query.def[(unsigned int)3] = "d";
>             query.def[(unsigned int)4] = "e";
>             query.def[(unsigned int)5] = "f";
>             query.def[(unsigned int)6] = "g";
>             query.parse();					       //If I comment this line, the program's memory
> doesn't change
>             std::cout << "query : " << query.preview() <<
> std::endl;//If I comment this line, the program's memory doesn't change


To determine if this is really a memory leak, you need to make sure that
you're freeing the memory.  In this case, any memory allocated by Query
will not be freed, since it is on the stack and doesn't free until after
main() returns.

You might try moving the Query object inside the for loop:

   for(int j=0;j<100000;j++) {
	mysqlpp::Query query = g_dbcon.query();
	...
   }
   // query goes out of scope here and is freed

If there is still a problem, then there might be a memory leak.

- Chris

Thread
plz help me.. there is a memory leak.. 18 Jan
  • Re: plz help me.. there is a memory leak..Denis ERCHOFF18 Jan
RE: plz help me.. there is a memory leak..최 종윤18 Jan
  • Re: plz help me.. there is a memory leak..Denis ERCHOFF18 Jan
RE: plz help me.. there is a memory leak..최 종윤18 Jan
  • Re: plz help me.. there is a memory leak..Drew Vogel18 Jan
RE: plz help me.. there is a memory leak..최 종윤19 Jan
  • Re: plz help me.. there is a memory leak..Chris Frey27 Jan
RE: plz help me.. there is a memory leak..최 종윤19 Jan
  • Re: plz help me.. there is a memory leak..Drew Vogel19 Jan
RE: plz help me.. there is a memory leak..최 종윤23 Jan