Jan-Henrik,
I'm getting reports of small leakage when I follow this pattern:
c = ConnectionPool_getConnection(pool); TRY // prepare and bind and execute statement, or // run or execute a query, with or without transactions CATCH(SQLException) // log exception // set volatile boolean result flag FINALLY Connection_close(c); END_TRY;
The try/accept block varies; but in all cases the connection leaks.
I'm attaching a stripped valgrind log which was posted to my bug-tracker.
So I wonder, is there something in the try...finally...end_try block I need to modify to prevent this?
Hello
A try-block should not per se cause any such problems [1]. I haven't seen a leaks in the MySQL driver before, though we don't use MySQL much in production so I cannot say definite.
I did a quick test just now and modified the test code, select.c, to run indefinitely 50 threads, each performing a query and creating a Result Set against a MySQL database[2]. I ran this through Instruments several times and AFAIK could not see any leaks [3].
I believe mysql_init allocates some initial resources at startup which are first released when mysql_library_end or mysql_server_end is called. Which is done in MysqlConnection_onstop via ConnectionPool_stop. This should not be interpreted as a leak so much as a deferred release.
I tested with mysql Ver 14.14 Distrib 5.6.13, for osx10.7 (x86_64) (libmysqlclient.18.dylib). If you have a test program that can reproduce _consistent_ leaks during runtime I'll be happy to take a look.
Jan-Henrik
1. Of course, if you have nested method calls in a try-block (call-stack) which allocate resources you need to wrap them in a try-block as well so you can intercept any exception thrown deeper down in the stack and release resources on the way up the call-stack. Try-finally is recommended in this case as this construct will intercept an exception, allow you to cleanup in the finally block and the original exception is automatically re-thrown at the end of END_TRY.
2.
3.
On Sep 9, 2013, at 10:55 AM, Paul J Stevens paul@nfg.nl wrote:
Jan-Henrik,
I'm getting reports of small leakage when I follow this pattern:
c = ConnectionPool_getConnection(pool); TRY // prepare and bind and execute statement, or // run or execute a query, with or without transactions CATCH(SQLException) // log exception // set volatile boolean result flag FINALLY Connection_close(c); END_TRY;
The try/accept block varies; but in all cases the connection leaks.
I'm attaching a stripped valgrind log which was posted to my bug-tracker.
So I wonder, is there something in the try...finally...end_try block I need to modify to prevent this?
-- ________________________________________________________________ Paul J Stevens pjstevns @ gmail, twitter, skype, linkedin
Premium Hosting Services and Web Application Consultancy *
www.nfg.nl/info@nfg.nl/+31.85.877.99.97
-- To unsubscribe: http://www.tildeslash.com/mailman/listinfo/libzdb-general
Ps. Please use the last version of libzdb (2.12). I see you use libzdb.so.8.0.3 in the log you sent and there has indeed been memory problems related to MySQL, but those should have been fixed back in 2.11.2
Best regards -- Jan-Henrik Haukeland http://tildeslash.com/ M: +47 97141255
-- To unsubscribe: http://www.tildeslash.com/mailman/listinfo/libzdb-general
-- To unsubscribe: http://www.tildeslash.com/mailman/listinfo/libzdb-general
On 09-09-13 16:14, Jan-Henrik Haukeland wrote:
Ps. Please use the last version of libzdb (2.12). I see you use libzdb.so.8.0.3 in the log you sent and there has indeed been memory problems related to MySQL, but those should have been fixed back in 2.11.2
Cool. I didn't produce the log. I'll pass on the info. Thanks for your input.