Re: [libdbi-users] Memory leak when using dbi_initialize in loop

2011-08-09 Thread Shakthi Kannan
Hi Markus,

--- On Thu, Aug 4, 2011 at 5:44 PM, Markus Hoenicka
markus.hoeni...@mhoenicka.de wrote:
| I had almost forgotten that bug. That's indeed the most likely reason that
| your test app leaks memory. Unfortunately you're not using an old version as
| 0.8.3 is the latest official release. The bug is fixed in the cvs version
| which, by all means, ist tested, stable, and reliable. I just won't have the
| time to finish a new release until September or so. So if that leak really
| hurts you, you'd have to build libdbi and libdbi-drivers from cvs.
\--

I checked out the latest cvs sources (August 9, 2011). For libdbi, I did:

  $ autogen.sh
  $ ./configure --disable-docs
  $ make
  $ sudo make install

For libdbi-drivers, I used:

  $ autogen.sh
  $ ./configure --with-mysql --with-mysql-libdir=/usr/lib/mysql
--with-mysql-incdir=/usr/include/mysql
--with-dbi-libdir=/usr/local/lib --disable-docs
  $ export LD_LIBRARY_PATH=/usr/local/lib

The API has been changed in the latest source. So, I updated the
following code snippet, and I still see the memory leak:

=== CODE ===

#include stdio.h
#include dbi/dbi.h

int main()
{
  dbi_conn conn;
  dbi_inst instance;

  dbi_initialize_r(NULL, instance);

  while (1) {

conn = dbi_conn_new_r(mysql, instance);

dbi_conn_set_option(conn, host, localhost);
dbi_conn_set_option(conn, username, foo);
dbi_conn_set_option(conn, password, bar);
dbi_conn_set_option(conn, dbname, test);
dbi_conn_set_option(conn, encoding, UTF-8);

if (dbi_conn_connect(conn)  0) {
  printf (Could not connect\n);
}
else {
  dbi_conn_close(conn);
}
  }

  dbi_shutdown_r(instance);
  return 0;

}

=== END ===

Is there anything that I am missing? Appreciate any inputs in this regard,

SK

-- 
Shakthi Kannan
http://www.shakthimaan.com

--
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
___
libdbi-users mailing list
libdbi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-users


Re: [libdbi-users] Memory leak when using dbi_initialize in loop

2011-08-09 Thread Shakthi Kannan
Hi Markus:

--- On Tue, Aug 9, 2011 at 4:51 PM,  markus.hoeni...@mhoenicka.de wrote:
| I've reproduced the leak that you detected in the current cvs
| sources. According to my analysis the drivers pass error messages
| through dbd_geterror() as allocated
| strings. _dbd_internal_error_handler() created another copy with
| strdup() which isn't necessary. The latter copy was freed, the
| original copy was left in place. I've fixed this leak in the current
| cvs revision.
\--

Which is the current cvs revision, and which file is it? I am not able
to see any commit logs at:

  http://sourceforge.net/mailarchive/forum.php?forum=libdbi-cvs

Thanks for your prompt response.

SK

-- 
Shakthi Kannan
http://www.shakthimaan.com

--
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
___
libdbi-users mailing list
libdbi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-users


Re: [libdbi-users] Memory leak when using dbi_initialize in loop

2011-08-04 Thread Shakthi Kannan
Hi Markus,

I came across this memory leak post:

  http://comments.gmane.org/gmane.comp.db.libdbi.devel/309

Is this fixed in the sources and am I using old version of the software?

libdbi-devel-0.8.3-4.fc14.i686
libdbi-0.8.3-4.fc14.i686
libdbi-drivers-0.8.3-6.fc14.i686
libdbi-dbd-mysql-0.8.3-6.fc14.i686

SK

-- 
Shakthi Kannan
http://www.shakthimaan.com

--
BlackBerryreg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos  much more. Register early  save!
http://p.sf.net/sfu/rim-blackberry-1
___
libdbi-users mailing list
libdbi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-users


Re: [libdbi-users] Memory leak when using dbi_initialize in loop

2011-08-03 Thread Markus Hoenicka
Shakthi Kannan shakthim...@gmail.com was heard to say:

 int main() {
   dbi_conn conn;

   while (1) {
 dbi_initialize(NULL);

[...]

 dbi_shutdown();
   }

   return 0;
 }

Hi,

I'll test your code on my dev box as soon as time permits. libdbi is  
not supposed to lose memory under any circumstances. I'll have to see  
the valgrind output as sometimes the leak is not within libdbi itself,  
but within a driver or the client library (if the driver forgets to  
free memory allocated by the library).

In any case, I'd suggest to modify your code. dbi_initialize() is  
supposed to be run once per process, so the following is more  
appropriate:

int main() {
   dbi_conn conn;

   dbi_initialize(NULL);
   while (1) {

[...]

   }
   dbi_shutdown();

   return 0;
}

If it is indeed libdbi that leaks memory, it won't do so in every  
cycle of your loop.

regards,
Markus

-- 
Markus Hoenicka
http://www.mhoenicka.de
AQ score 38



--
BlackBerryreg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos  much more. Register early  save!
http://p.sf.net/sfu/rim-blackberry-1
___
libdbi-users mailing list
libdbi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-users