List:Internals« Previous MessageNext Message »
From:Sasha Pachev Date:September 3 2001 5:21pm
Subject:Re: Memory leaks?
View as plain text  
On Monday 03 September 2001 07:42, Tobias Rundstr?m wrote:
> Hello.
> I'd like to have some help with a memoryleak. It's probably in my
> clientprogram but I can't find anywhere in the documentation how to free
> this memory. I found the leak using dbx under solaris. here is the trace for
> the leak.
> 
> Found 4 leaked blocks with total size 32656 bytes
> At time of each allocation, the call stack was:
>         [1] my_malloc() at 0xe610adb0 
>         [2] alloc_root() at 0xe610de64 
>         [3] unpack_fields() at 0xe6106334 
>         [4] mysql_read_query_result() at 0xe61078c4 
>         [5] mysql_real_query() at 0xe6108624 
>         [6] our_mysql_query() at line 211 in "mysql.c"
> 
> the relevant line in mysql.c reads: 
> 
>         if (mysql_real_query(mysql,query,strlen(query))){

mysql_real_query() can appear to a memory leak checker to leak because it 
uses alloc_root() - our own internal memory allocation pool code. The 
important thing is:

 * if you call mysql_real_query() several times, the amount of the "leak" 
should not be growing outrageously, and should stay at around the total 
length of the field names + a little overhead

 * leak should disappear after mysql_close()

-- 
MySQL Development Team
For technical support contracts, visit https://order.mysql.com/
   __  ___     ___ ____  __ 
  /  |/  /_ __/ __/ __ \/ /   Sasha Pachev <sasha@stripped>
 / /|_/ / // /\ \/ /_/ / /__  MySQL AB, http://www.mysql.com/
/_/  /_/\_, /___/\___\_\___/  Provo, Utah, USA
       <___/                  
Thread
Memory leaks?Tobias Rundström3 Sep
  • Re: Memory leaks?Sasha Pachev3 Sep
    • Re: Memory leaks?Tobias Rundström4 Sep
      • Re: Memory leaks?Sasha Pachev4 Sep
  • Re: Memory leaks?Paul Cadach4 Sep
  • Memory leaks?Michael Widenius5 Sep