MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Attila Date:January 19 2010 2:22am
Subject:mysqlpp::Connection memory leak?
View as plain text  
Hi Everyone,

I have an application that uses a custom made DBConnectionPool.
The architecture is basically as follows:

All of the components (DBConnectionPool and DBWorker) run in their own
strands (all work is queued, so no explicit locking is required), that
is...  all work is run via threadpool threads.

DBConnectionPool passes out connections.
DBWorker's accept work (in the form of adding DBWork to it's list to process
when a connection is received)
  --> These DBWorkers will request a connection from the pool, the pool then
queues a connection for usage back to the DBWorker (when a connection
becomes available)

That all being said, I am using the thread aware libraries of mysql and
mysqlpp.

Here are a couple of stack traces I get on application shutdown from a
memory leak detector (using VLD 1.0 on VS 9.0):

Connect related:

  Call Stack:
    f:\dd\vctools\crt_bld\self_x86\crt\src\dbgmalloc.c (56): malloc

g:\mysql-5.1.30-winbuild\mysql-community-debug-5.1.30-build\mysys\my_once.c
(61): my_once_alloc

g:\mysql-5.1.30-winbuild\mysql-community-debug-5.1.30-build\mysys\charset.c
(62): init_state_maps

g:\mysql-5.1.30-winbuild\mysql-community-debug-5.1.30-build\mysys\charset.c
(435): init_available_charsets

g:\mysql-5.1.30-winbuild\mysql-community-debug-5.1.30-build\mysys\charset.c
(577): get_charset_by_csname

g:\mysql-5.1.30-winbuild\mysql-community-debug-5.1.30-build\sql-common\client.c
(1780): mysql_init_character_set

g:\mysql-5.1.30-winbuild\mysql-community-debug-5.1.30-build\sql-common\client.c
(2177): mysql_real_connect
    c:\p4\dev\aa1\libs\extlibs\mysql++-3.0.8\lib\dbdriver.cpp (89):
mysqlpp::DBDriver::connect
    c:\p4\dev\aa1\libs\extlibs\mysql++-3.0.8\lib\connection.cpp (98):
mysqlpp::Connection::connect
    c:\p4\dev\aa1\libs\toolsdatabase\mysqlppconnection.cpp (52):
db::MySQLppConnection::MySQLppConnection
    c:\p4\dev\aa1\rstsrc\libs\toolsdatabase\mysqlppconnectionfactory.cpp
(41): db::MySQLppConnectionFactory::CreateDBConnection
    (...omitted)

I also get a store-related memory leak:

 Call Stack:
    f:\dd\vctools\crt_bld\self_x86\crt\src\dbgmalloc.c (56): malloc
    g:\mysql-5.1.30-winbuild\mysql-community-debug-5.1.30-build\dbug\dbug.c
(2022): DbugMalloc
    g:\mysql-5.1.30-winbuild\mysql-community-debug-5.1.30-build\dbug\dbug.c
(345): code_state
    g:\mysql-5.1.30-winbuild\mysql-community-debug-5.1.30-build\dbug\dbug.c
(967): _db_enter_

g:\mysql-5.1.30-winbuild\mysql-community-debug-5.1.30-build\sql-common\client.c
(2837): mysql_real_query
    c:\p4\dev\aa1\libs\extlibs\mysql++-3.0.8\lib\dbdriver.h (199):
mysqlpp::DBDriver::execute
    c:\p4\dev\aa1\libs\extlibs\mysql++-3.0.8\lib\query.cpp (481):
mysqlpp::Query::store
    c:\p4\dev\aa1\libs\extlibs\mysql++-3.0.8\lib\query.cpp (472):
mysqlpp::Query::store
    c:\p4\dev\aa1\libs\extlibs\mysql++-3.0.8\include\query.h (467):
mysqlpp::Query::store
    c:\p4\dev\aa1\libs\toolsdatabase\mysqlppconnection.cpp (212):
db::MySQLppConnection::SelectExec
    (...omitted)


I know that I am cleaning up my wrapper objects correctly. MySQLppConnection
has an auto_ptr to mysqlpp::Connection and I know the destructors are being
called.

Versions I am using:

mysqlpp:  3.0.8
mysql:  5.1.30
Running mysql server instance: 5.1.41


Questions:

Is my combination of versions incorrect?
Should I be using the mysql-c libraries for the same version as the running
server instance?
If I am passing a mysqlpp::Connection object around to different objects (in
different threads) -- could it cause a memory leak or other problems? (I can
guarantee that only 1 thread is using a connection at any given point)


Thanks for your help,

-- 
Attila
Software Developer
atteeela@stripped

Thread
mysqlpp::Connection memory leak?Attila19 Jan
  • Re: mysqlpp::Connection memory leak?Attila19 Jan