Elm Gysel writes: > Hello, > > I have a memory problem when added records to a table. > The situation is like this (simplyfied) : > > query << "select id, symbol from " << STOCKS_TABLE_NAME << std::ends; > std::vector<vse_symbol_id> symbols; > query.storein(symbols); > std::vector<vse_symbol_id>::iterator I; > for(I = symbols.begin(); I != symbols.end(); I++) { > query.reset(); > query << "select max(date_time) from " << HISTORY_TABLE_NAME << > " where symbol_id='" << I->id << "'"; > Result result = query.store(); > > query << "insert into " << HISTORY_TABLE_NAME << > " values(%0, %1, %2, %3, %4, %5, %6)"; > /** let query object know this is a template and not a normal query */ > query.parse(); > > (for loop that will insert 2000 records each time) > for(.....) { > /** get date */ > .... > /* perform query */ > query.execute(nr, Date.str(), Op, Hi, Lo, Cl, Vo); > The problem is in the above line I think. If I comment it out the memory > usage doesn't explode. > I get around 1.5MB more mem usage each time I insert 2000 records. > I have no clue what might go wrong here. > } > } > > > After 10 times adding 2000records I have a memory usage of like 30MB. Are > there any memory leaks involved in using the query object? Am I doing > something wrong? > > > Thanks for any help! > > Elm
Hi! The only possible cause for memory being used more, is in member field str of the type SQLString. If your query object is local, or that memory will be freed automatically at the end of the block. It is possible that it is a memory leak, and it would be nice if you could try out one thing. If you would add str.empty() in the execute method in query2.hh and re-build MySQL++ and your program and check memory usage then, that would be very nice of you. -- Regards, __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Mr. Sinisa Milivojevic <[EMAIL PROTECTED]> / /|_/ / // /\ \/ /_/ / /__ MySQL AB, FullTime Developer /_/ /_/\_, /___/\___\_\___/ Larnaca, Cyprus <___/ www.mysql.com --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php