List:General Discussion« Previous MessageNext Message »
From:Fred Lindberg Date:April 15 1999 2:05pm
Subject:Re: Memory leaking like a sieve in mysql client api.
View as plain text  
On Thu, 15 Apr 1999 02:00:56 -0500, Benjamin Scherrey wrote:

>void test2( const char* db, const char* host, const char* user, const
>char* pwd )
>{
>    for( int i = 0;i<3000;i++ )
>    {
>        MSQL* mysql = mysql_init( NULL );
>
>        if( !mysql_real_connect( mysql, host, user, pwd, 0, NULL, 0 ) )
>        {
>            cout << mysql_error( mysql ) << endl;
>            exit(1);
>        }
>
>        mysql_close( mysql );
>    }
>};

You're allocating 3000 structures for mysql connections. The API
obliges. You allocate it to the same pointer. There is your memory
leak, coded by you.


-Sincerely, Fred

(Frederik Lindberg, Infectious Diseases, WashU, St. Louis, MO, USA)


Thread
Memory leaking like a sieve in mysql client api.Benjamin Scherrey15 Apr
  • Re: Memory leaking like a sieve in mysql client api.Benjamin Scherrey15 Apr
  • Re: Memory leaking like a sieve in mysql client api.Benjamin Scherrey15 Apr
  • Re: Memory leaking like a sieve in mysql client api.Benjamin Scherrey15 Apr
  • Re: Memory leaking like a sieve in mysql client api.Benjamin Scherrey15 Apr
    • Re: Memory leaking like a sieve in mysql client api.Michael Widenius15 Apr
  • Memory leaking like a sieve in mysql client api.Michael Widenius15 Apr
  • Re: Memory leaking like a sieve in mysql client api.Benjamin Scherrey15 Apr
    • Re: Memory leaking like a sieve in mysql client api.Michael Widenius16 Apr
      • Re: Memory leaking like a sieve in mysql client api..16 Apr
        • Re: Memory leaking like a sieve in mysql client api.Michael Widenius17 Apr
Re: Memory leaking like a sieve in mysql client api.Fred Lindberg15 Apr
Re: Memory leaking like a sieve in mysql client api.Fred Lindberg15 Apr