[unixODBC-support] Memory leaks in sql calls

Song, Cavin csong at Securify.com
Tue Oct 2 18:02:37 BST 2007


Hi,

I'm new to this mailing list and I have a question regarding memory
leaks with the following sql query calls (execute() and
executeUpdate()):

  void test()
  {
    PreparedStatement* p=my_conn->prepareStatement("drop table abcdef");
    try {
       p->executeUpdate();
    } catch(SQLException& e) { }

    delete p;
  }

  void test1()
  {
    Statement *p = my_conn->createStatement();
    string sql = ""drop table abcdef";
    p->execute( sql );
    delete p;
  }

where my_conn = DriverManager::getConnection(*my_dsn, *my_username,
*my_password);

If either of the above function is called 13,000 times in a look the
leak is about 19-20 MB:

  for (int i=0; i<13000; i++)
  {
    test();  // or test1();
  }

I'm using an old version of unixobdc and odbc++ and I'm wondering if the
leak problem(s) has been fixed in the lastest verison of unixobdc and
odbc++. The database is Sybase and the 'dmtest' program (not sure if
this helps) shows:

Available datasources:
        local (FreeTDS)
Available drivers:
        FreeTDS
                Attribute: Description=FreeTDS
                Attribute: Driver=/usr/local/lib/libtdsodbc.so.0
                Attribute: Setup=/usr/local/lib/libtdsS.so.1
                Attribute: FileUsage=1
                Attribute: CPTimeout=
                Attribute: CPReuse=

Thank you for your help.

Cavin Song



More information about the unixODBC-support mailing list