List:MySQL++« Previous MessageNext Message »
From:Bruno Adami Date:May 11 2009 7:12pm
Subject:RE: Possible memory leak?
View as plain text  
I found a solution. Looking trough the lists of Mysql C Api, I found this topic:

http://bugs.mysql.com/bug.php?id=7619

Read what Sergei Golubchik wrote.

So, when I finish my application I put the mysql_library_end(), and the leak desapears!

Look Valgring output:

==10374== Memcheck, a memory error detector.
==10374== Copyright (C) 2002-2008, and GNU GPL'd, by Julian Seward et al.
==10374== Using LibVEX rev 1884, a library for dynamic binary translation.
==10374== Copyright (C) 2004-2008, and GNU GPL'd, by OpenWorks LLP.
==10374== Using valgrind-3.4.1-Debian, a dynamic binary instrumentation framework.
==10374== Copyright (C) 2000-2008, and GNU GPL'd, by Julian Seward et al.
==10374== For more details, rerun with: -v
==10374== 
Check1
Check2
Check3
Check4
Check5
==10374== 
==10374== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 31 from 2)
==10374== malloc/free: in use at exit: 0 bytes in 0 blocks.
==10374== malloc/free: 124 allocs, 124 frees, 157,076 bytes allocated.
==10374== For counts of detected errors, rerun with: -v
==10374== All heap blocks were freed -- no leaks are possible.

And the code:

#include <iostream>
#include <mysql++/mysql++.h>

void test();

int main()
{
    //mysql_library_init();
    test();
    mysql_library_end();
    return 1;
}

void test()
{
    std::cout << "Check1" << std::endl;
    mysqlpp::Connection conn;
    std::cout << "Check2" << std::endl;
    conn.disable_exceptions();
    std::cout << "Check3" << std::endl;
    if (!conn.connect("Kakele","127.0.0.1","root","kakele1990",8080))
    {
        std::cout << "error!" << std::endl;
        return;
    }
    std::cout << "Check4" << std::endl;
    conn.disconnect();
    std::cout << "Check5" << std::endl;
}

_________________________________________________________________
Descubra todas as novidades do novo Internet Explorer 8
http://brasil.microsoft.com.br/IE8/mergulhe/?utm_source=MSN%3BHotmail&utm_medium=Tagline&utm_campaign=IE8
Thread
Possible memory leak?Bruno Adami11 May
  • RE: Possible memory leak?Mark Easton11 May
  • Re: Possible memory leak?Warren Young11 May
    • RE: Possible memory leak?Bruno Adami11 May
    • RE: Possible memory leak?Bruno Adami11 May
      • RE: Possible memory leak?Kevin Stevens11 May
  • RE: Possible memory leak?Bruno Adami11 May
    • RE: Possible memory leak?Mark Easton11 May
    • Re: Possible memory leak?Warren Young11 May