From: Benjamin Scherrey Date: April 15 1999 4:19pm Subject: Re: Memory leaking like a sieve in mysql client api. List-Archive: http://lists.mysql.com/mysql/1911 Message-Id: <3716119E.B6D681C2@gte.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit OK - this is what was biting me and led to the other problems. I need to be able to init a MSQL structure then close it without having a connection because this occurs in the ctor/dtor respectively of a class. An instance of that class may come into and out of existence without ever having made a connection which results in my application locking up. I'd prefer a code workaround rather than patching the libmysql.c source because this program will get deployed on multiple boxes and don't want to have custom MySQL builds all over the place. This leaves me with two questions: A) Is there something I can test in the MYSQL structure to confirm its safe to close it? B) Will you include the code fix for libmysql.c in future releases of MySQL and make this problem go away? thanx much, Ben Scherrey Michael Widenius wrote: > >>>>> "Benjamin" == Benjamin Scherrey writes: > > Benjamin> I'm getting some unusual behavior out of the mysql client apis. Try the > Benjamin> following: > > Benjamin> // test1 results in your code never returning. > Benjamin> void test1( void ) > Benjamin> { > Benjamin> MYSQL* mysql = mysql_init( NULL ); > > Benjamin> mysql.close( mysql ); > Benjamin> }; > > This doesn't return because the API requires that you call mysql_real_connect() > or mysql_connect() after mysql_init(). > > Here is a fix if you really want to do the above: > > *** /my/monty/master/mysql-3.22.21/client/libmysql.c Mon Feb 22 14:10:54 1999 > --- ./libmysql.c Thu Apr 15 14:15:20 1999 > **************** > *** 902,907 **** > --- 902,908 ---- > if (!(mysql=(MYSQL*) my_malloc(sizeof(*mysql),MYF(MY_WME | MY_ZEROFILL)))) > return 0; > mysql->free_me=1; > + mysql->net.fd= INVALID_SOCKET; > } > else > bzero((char*) (mysql),sizeof(*(mysql)));